Linux ERRORLEVEL equivalent?

Started by Chavo, April 16, 2007, 11:03:04 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Chavo

I have a simple script that I use to keep an application running on a windows machine:


:loop
;// execute a shell command
IF ERRORLEVEL == 1 GOTO loop
pause > nul


The program this is keeping alive I'm wanting to move to an offsite server that is running Linux.  Obviously I'll need to convert the script to something bash can understand, but the ERRORLEVEL variable is where I am lost.  ERRORLEVEL in Windows is a variable that holds the integer return value of the last command that executed.  For any normal program termination that is usually 0.  I have this particular program set to return 1 (System.exit(1)) when there is an error.  It logs the error on its own and this script restarts the program.  Anyone know the linux equivalent?

Skywing

Assuming you're using something compatible with /bin/sh, $? perhaps?

Chavo

#2
yea


#!/bin/bash
# Simple keep-alive script

until (( ERRORLEVEL == 1 ))
do
  #start program
done

exit


Just need to figure out how to replace the ERRORLEVEL conditional


Chavo

You'll forgive me if a question mark looks like a question ;)

That will work nicely, thanks.