Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script question

Status
Not open for further replies.

Glory2G0D

Technical User
Sep 20, 2004
19
0
0
US
In going through some scripts on one of our servers, I found the following:

if [ $? == 0]
then
echo "$i, $ADDR" >> ipaddr.ep
fi

What does the [$? == 0] mean?

Thanks,
Glory2G0d
 
What does the [ $? == 0 ] mean?
Is the exit code of the last command equal zero ?
Feel free to take a look at your shell man page.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 

If the result (exit code) of the last command ($?) is equal (==) to zero (0) then ....


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Sorry for my not understanding. The following is the whole script:

#!/bin/sh

if test -r ipaddr.ep
then
rm ipaddr.ep
fi

for i in `wlookup -ar Endpoint -L`
do
echo "Getting the address of $i"
ADDR=`wep $i get address`

if [ $? == 0]
then
echo "$i, $ADDR" >> ipaddr.ep
fi
done

Is the exit code for the last command the ADDR line? Thanks again.

Glory2G0D

 
Seems that $? refers to the exit code of the wep command.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I needed a reminder on what exit codes were. Thanks for your help, this is now resolved for me.

Glory2G0D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top