Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expect question 1

Status
Not open for further replies.

alan147

Technical User
Nov 15, 2002
128
GB
Good afternoon

I am trying to use expect to interact with an ftp site, but I need to be able to pass a parameter to the expect script. If I don't set the shell the $1 variable is not recognised, if I set the shell expect fails.

Any ideas.

Thanks, Alan
 
I got an expect script as below. I dont remember the poster. See how using set and [lindex] you can pass parameters. Is this what you were looking for?
Code:
#! /usr/bin/expect
spawn passwd [lindex $argv 0]
set password [lindex $argv 1]
set npasswor [lindex $argv 2]
expect "password:"
send "$password\r"
expect "password:"
send "$npasswor\r"
expect "password:"
send "$npasswor\r"
expect eof
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top