开发者

using command line argument while using expect

开发者 https://www.devze.com 2023-03-02 19:06 出处:网络
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

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 f开发者_运维知识库ollows:

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?


Replace $1 with [lindex $argv 0]. The $argc variable tells the number of given arguments.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号