Ammu
Ammu

Reputation: 5127

using command line argument while using expect

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?

Upvotes: 4

Views: 6447

Answers (1)

maxelost
maxelost

Reputation: 1567

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

Upvotes: 11

Related Questions