Re: scripting help
- From: "Steven W. Orr" <steveo@xxxxxxxxxxx>
- Date: Fri, 29 Sep 2006 16:10:19 -0400 (EDT)
On Friday, Sep 29th 2006 at 19:56 +0100, quoth Tom Brown:
=>
=>> 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)
=>
=>i am trying to get a plugin to work that uses snmp to execute checks on remote
=>hosts over snmp and return that value to nagios. I was using this as an
=>assistance
=>
=>http://www.kilala.nl/Sysadmin/retrieve_custom_snmp.php
=>
=>i am no developer thats for sure but i will try to muddle through.
=>
=>any more help appreciated
=>
=>thanks
This might help. Any program that you run can produce output. Any program
that cleanly exits will produce an exit code. You can save the output of a
program through tricks like this
prog > file
The exit code is referenced from shell scripts via the variable $?. It
always contains the value of the exit code of the last command. So if you
need to examine the exit status of something from a few commands ago,
then you need to save it in a variable.
prog
EXITCODE=$?
blah
blah
if (( EXITCODE != 0 ))
then
# Now we're in trouble...
The use of backquotes causes a command to return the output of the
program.
foo=`prog`
will be equal to the text of whatever was writen during the run of prog.
Make sense?
--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
- References:
- scripting help
- From: Tom Brown
- Re: scripting help
- From: Paul Howarth
- Re: scripting help
- From: Tom Brown
- Re: scripting help
- From: Paul Howarth
- Re: scripting help
- From: Tom Brown
- Re: scripting help
- From: Steven W. Orr
- Re: scripting help
- From: Tom Brown
- scripting help
- Prev by Date: Re: top posting netiquette
- Next by Date: Re: scripting help
- Previous by thread: Re: scripting help
- Next by thread: Re: scripting help
- Index(es):
Relevant Pages
|