Re: scripting help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday, Sep 29th 2006 at 19:31 +0100, quoth Tom Brown:

=>
=>> > if [ $EXITCODE -eq 0 ]; then
=>> >     echo "$OUTPUT" | grep -v CRITICAL
=>> >     [ $? -eq 1 ] && EXITCODE=2
=>> > fi
=>> > 
=>> > but when the script runs i get this
=>> > 
=>> > ../libexec/retrieve_custom_snmp: line 84: [: -eq: unary operator expected
=>> > "CRITICAL emcpowera has 2 dead, 2 alive"
=>> > 
=>> > can anyone help with this issue
=>> 
=>> What is $EXITCODE set to? How is it set?
=>
=>EXITCODE=`$SNMPWALK -v 1 -c $COMMUNITY $HOST $STATUS`
=>[ $DEBUG -gt 0 ] && echo "Retrieve exit code is $EXITCODE" >> $DEBUGFILE

You set the variable EXITCODE to the standard output of the SNMPWALK 
command. I have no idea what you want to do with the output but to check 
the exit status you want something like this:

$SNMPWALK -v 1 -c $COMMUNITY $HOST $STATUS
EXITCODE=$?

Also, do not use backquotes when you can use $( cmd ) instead.

output=$($SNMPWALK -v 1 -c $COMMUNITY $HOST $STATUS)

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux