在使用expect时使用命令行参数(using command line argument while using 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?
最满意答案
用[lindex $argv 0]替换$1 。 $argc变量告诉给定参数的数量。
Replace $1 with [lindex $argv 0]. The $argc variable tells the number of given arguments.
更多推荐
发布评论