LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-25-2008, 04:12 PM   #1
MattFunke
LQ Newbie
 
Registered: Mar 2006
Distribution: TSLinux 3.0, RedHat Enterprise 4
Posts: 16

Rep: Reputation: 0
Why does this Expect script fall through on failure?


Can anyone tell me why this script attempts to expect the second block if the first block fails?:

#!/usr/bin/expect

set timeout 20

spawn snmpwalk -v 2c -c public [lindex $argv 0] system

expect {
timeout {send_user "Timed out...\n"; exec ./checker snmpwalk[lindex $argv 0]#00 FAIL; exit}
-ex "SNMPv2-MIB::sysDescr.0 = STRING: Linux csi-dsp2-dualband 2.4.32 #1" {exec ./checker snmpwalk[lindex $argv 0]#00 PASS}
}

expect {
timeout {send_user "Timed out...\n"; exec ./checker snmpwalk[lindex $argv 0]#01 FAIL; exit}
-ex "SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10" {exec ./checker snmpwalk[lindex $argv 0]#01 PASS}
}


Here's the error I get:

spawn snmpwalk -v 2c -c public 192.168.1.200 system
Timeout: No Response from 192.168.1.200
expect: spawn id exp4 not open
while executing
"expect -nobrace timeout {send_user "Timed out...\n"; exec ./checker snmpwalk[lindex $argv 0]#01 FAIL; exit} -ex {SNMPv2-MIB::sysObjectID.0 = OID: NET-..."
invoked from within
"expect {
timeout {send_user "Timed out...\n"; exec ./checker snmpwalk[lindex $argv 0]#01 FAIL; exit}
-ex "SNMPv2-MIB::sysObjectID.0 = OID: NET..."
(file "./exp_snmp" line 12)


It was my impression that "exit" exits even multi-threaded apps in Tcl. So why does the expect script simply skip to the next block?

Thanks in advance for any help you can lend.
 
Old 03-27-2008, 03:02 AM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
It does not execute the second block because the application simply stops executing when a timeout occurs. In other words, it doesn't handle your timeout correctly and it terminates immediately.

Interesting way to call SNMP from TCL though. Didn't think about it, have problem calling SNMP from TCL. Yesterday I posted this question It never appeared to me to do it like you do.

For your problem, include this statement in your program at the beginning:
Code:
exp_internal 1
and I expect that you can see why timeout is not handled gracefully.

jlinkels
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Expect Script coolest Programming 7 02-16-2009 03:59 PM
Troubleshooting script that uses expect kaplan71 Linux - Software 4 02-29-2008 05:23 PM
Combined bash and expect script Paul77 Linux - Software 11 03-08-2007 09:17 AM
Script... variables with expect? Manana Linux - Networking 1 01-19-2007 04:41 AM
How to combine Expect and Shell script Uday123 Programming 0 12-27-2005 09:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration