1833758 Members
2750 Online
110063 Solutions
New Discussion

expect parms from file

 
jerry1
Super Advisor

expect parms from file

I still cannot find out how to separate two to
three parameters from a input file using Expect. Anyone know how?

Here is what I have so far. I can read each
line from the file but how do you tell Expect
to read each entry in the line as a separate
variable.

#!/opt/expect/bin/expect -f

# Querey jetdirect cards and/or change config.


set dfile "./printers" ;# Printer hostnames
and new IP address
and gateway IP.

set file [open $dfile r]
while {![eof $file]} {
if {-1 == [ gets $file line ]} break ;
spawn telnet $line
expect {
"Password:" {
send "^]"
expect "telnet> "
send "quit\r"
expect "Connection closed.\r"
}
"For HELP type \"?\"" {
expect "> "
send "?\r"
#send "\r"
expect "> "
send "/\r"
expect "> "
send "exit\r"
expect "Connection closed by foreign host.\r"
}
"> " {
send "/\r" ;
expect {
"Press RETURN to continue:" {
send "\r" ;
expect "Press RETURN to continue:"
send "\r"
expect "Press RETURN to continue:"
send "\r"
send "\r"
expect "> "
send "exit\r"
expect "Connection closed by foreign host.\r"
}
"> " {
send "exit\r" ;
expect "Connection closed by foreign host.\r"
}
}
expect "*unknown*" ;# Just ignore anything else.
}
}
}


1 REPLY 1
George Spencer_3
New Member

Re: expect parms from file

Assume the line is a list, and run something like:

foreach host $line {
...
}

Just an idea!