Using command line argument when using

Hi, I am using the mput file function for a remote machine. I pass the file name as a command line argument to the script. But the error is thrown 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 you suggest what is wrong here?

+3
source share
1 answer

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

+10
source

All Articles