LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   expect question (http://www.linuxquestions.org/questions/programming-9/expect-question-256667/)

reitzell 11-18-2004 10:37 PM

expect question
 
I had to change like 40 devices SNMP community strings. I had a file of all of the devices called iplist that simply had the IP addresses listed 1 on each line. I was thinking I could simply “for foo in `cat iplist`; do snmpwork $foo; done but I ran into a little problem.

#!/usr/bin/expect –f

proc show-snmp {gateway user password]
spawn telnet $gateway

<snip>

set user robw
set password test

show-snmp [lindex $argv 0] $user $password

This didn’t work but if I spawned telnet and then opened $gateway it did.

#!/usr/bin/expect –f

proc show-snmp {gateway user password]
spawn telnet
expect ">" {send "open $gateway\n"}

<snip>

set user robw
set password test

show-snmp [lindex $argv 0] $user $password

Any idea why?

reitzell 11-20-2004 09:03 AM

I think I didn't word this well.

I am going to figure out how to do this kind of thing in perl.

So today, chapt 1 learning perl. :)

Thanks anyways,
Rob


All times are GMT -5. The time now is 01:56 PM.