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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Variables To Expect

Status
Not open for further replies.

FinnMan

Technical User
Feb 20, 2001
75
US
I have simple expect script that I want to pass a variable to via a web form. Any suggestions on how this can be done? One method I've seen is to dynamically generate the expect by using a simple echo from bash and then executing the expect script. Is there a way to pass the variable to expect with doing such dynamic generation?

*********************************************
#!/usr/local/bin/expect -f
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
spawn ssh -l userid hostname
match_max 100000
expect -exact "userid's password: "
send -- "password\r"
expect -exact "\r\r blah blah blah"
send -- "./tshoot VARIABLE> test.html\r"
exec sleep 3
send -- "exit\r"
expect eof

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top