Re: scripting help



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



Relevant Pages

  • Re: How to set exit code of non-console app?
    ... NOT yet returned an exit code to Windows (even though it has returned ... control to the command prompt, ... behavior does NOT occur if executing within a command script."). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: "FFIND" Exit Codes?
    ... || and to issue exit code `0' if it finds any, `1', if it does not. ... | IF ERRORLEVEL 1 GOTO NO-NEW-FILES ... | Could someone provide the syntax to check the FFIND exit codes as ... FFIND is an internal command. ...
    (comp.os.msdos.4dos)
  • Re: Deploy Adobe Acrobat 6.0 using sms 2003
    ... >I tried to install Adobe Acrobat 6.0 using sms 2003 without much luck. ... > "This is what I put in my sms package command line: ... A failure exit code of 1624 was returned. ...
    (microsoft.public.sms.swdist)
  • RE: office 2003 deployment - too general of a error message
    ... I have the transform in the same directory as the package. ... I have the command line as follows ... A failure exit code of 1624 was returned. ... Systems Management Server (SMS) determines status for each ...
    (microsoft.public.sms.swdist)
  • Re: [OT] Changing the case of filenames
    ... =>in trying to use this from the command line (or even in a bash script). ... Time flies like the wind. ... Stranger things have .0. ...
    (Fedora)