gryf has asked for the wisdom of the Perl Monks concerning the following question:
The first call to this method appears to works fine, even though the child process prints an error to STDERR. The method completes normally. Subsequent calls fail. Here's the output, the test script hits two separate mibtable, if the order is reversed, the second one would succeed.sub if ($? > 0 ) { $? = 0; } if ( defined(SNMP) ) { close SNMP; } print " /@/ gettable called ($?)\n"; my ($target,$table,$fieldstring,$comstr) = @_; $snmpCmd = "mibtable -table $table -fields $fieldstring -node $ta +rget |"; open (SNMP, $snmpCmd ) || die print STDERR "Couldn't open pipe +: $! \/ $? \/ $@\n"; $error = $?; while (<SNMP>) { # do stuff } my $closed = 13; $closed = close (SNMP) || $! ? "Error closing sort pipe: $!" : "Exit status $? from sort"; print "\tDid filehandle get closed: '$closed'\n"; undef SNMP; print STDERR "!!!! $! \/ $? \/ $@\n";
All I know is that the 'mibtable' command is returning "Error retrieving information from node No response arrived before timeout" to STDERR and $? is being set to 256. Despite the filehandle SNMP being closed and undeffed, subsequent attempts to use the method fail because, presumably, the filehandle is jammed in some way. It doesn't clear until the perl script exits. BTW- I'm using Perl 5.6.1. Any ideas how to clear the FH so I can reuse the method? Thanks!dncms@case3 ~ 621 > perl testSnmp2.pl node /@/ gettable called (0) snmpCmd: 'mibtable -table table1 -fields fields1 -node node |' pid: 1168 -1- (bootflash + 65451748 65536000) -2- (sw1-slot2-dfc-bootflash + 15990784 15990784) -3- (sw1-slot3-dfc-bootflash + 15990784 15990784) -4- (sw1-slot6-dfc-bootflash + 15990784 15990784) -5- (sw1-slot7-dfc-bootflash + 15990784 15990784) Error retrieving information from node No response arrived before timeout Did filehandle get closed: 'Exit status 256 from sort' !!!! / 256 / END GETTABLE (What is $?: 256) Errno from pipe: (piped exit code: 1) / (signal: 0) / (core dump: 0) [ +0] What is $?: 256 /@/ gettable called (0) snmpCmd: 'mibtable -table table1 -fields fields2 -node node |' pid: 1171 Error retrieving information from node No response arrived before timeout Did filehandle get closed: 'Exit status 256 from sort' !!!! / 256 / END GETTABLE What is $?: 256
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Jammed FH pipe
by ikegami (Patriarch) on Oct 07, 2009 at 21:08 UTC | |
by gryf (Novice) on Oct 07, 2009 at 22:21 UTC | |
by ikegami (Patriarch) on Oct 07, 2009 at 22:57 UTC | |
by cdarke (Prior) on Oct 08, 2009 at 07:20 UTC |