| |||||||||||
expect logic Posted by pret (pret), 3 January 2006 hi iam new to expect infact new to scriptingset PING "ping" proc newpingDev { newipAddr } { global PING PING_TIMEOUT exp_send -- "$PING $newipAddr\r" # spawn ping $newipAddr\r while (1) { expect { "*bytes from * time*" { return "SUCCESS" } "*is alive*" { return "SUCCESS" } "*Destination Host Unreachable*" { return "FAILED" } "*Network is unreachable*" { return "FAILED" } "*no answer from*" { return "FAILED" } "unknown host" { return "FAILED" } "*Usage*" { return "FAILED" } timeout { return "FAILED" } } } } set newip "160.48.58.39" set devIp "1.1.1.1" set rval [eval newpingDev $devIp] puts " the return value from newiptest is $rval" if { $rval == "FAILED" } { set _rval [eval newpingDev $newip] puts " the return value from newiptest is $_rval" } the new ip is pingabble and devip is dummy ip so when i i run the script with send its says both the ip are not pingable and returns failed where as when i use spawn ping ipadrres in the function i could ping the second ip why i sthis happ.i need to use send command instead of spawn .canu pls help ..this is a test program my real program is when the first ping failed to ping address then it should ping then next one but when i use send command thats not working i telnet in to multiple device and pipng it so after telnet i cannot spawn a ping sesssion so i need to use a send command but its not working ..any help pls Posted by admin (Graham Ellis), 4 January 2006 1. You say "it's not working". Can you tell us what actually happens as that will give a further clue as to what is going wrong.2. You mention telnet, but I don't see any spawn of a telnet - perhaps the program you've posted is incomplete? If you could come up with a short, complete example showing what's going wrong we might be able to help you a little better. Use spawn to start a process, then send and expect to communicate with it; if you don't start off with a spawn, you can't send or expect. This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |