在使用 Expect 的同时使用命令行参数
您好,我正在使用 Expect 将文件传输到远程计算机。我将文件名作为命令行参数传递给脚本。但是从该行抛出错误
send -- "mput $1\r"
我的代码如下:
set timeout 1000
spawn ftp $ipaddress
expect "Name "
send -- "$username\r"
expect "Password"
send -- "$passwd\r"
expect "ftp>"
send -- "mput $1\r"//error thrown from this line
expect "mput $1? "
send -- "y\r"
expect "ftp>"
send -- "bye\r"
有人可以建议这里出了什么问题吗?
Hi I am using expect to mput a file to a remote machine.I am passing the filename as a command line argument to the script.But error is throwing from the line
send -- "mput $1\r"
My code is as follows:
set timeout 1000
spawn ftp $ipaddress
expect "Name "
send -- "$username\r"
expect "Password"
send -- "$passwd\r"
expect "ftp>"
send -- "mput $1\r"//error thrown from this line
expect "mput $1? "
send -- "y\r"
expect "ftp>"
send -- "bye\r"
Could anyone please suggest what is wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
$1
替换为[lindex $argv 0]
。$argc
变量告诉给定参数的数量。Replace
$1
with[lindex $argv 0]
. The$argc
variable tells the number of given arguments.