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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

aploogies for the simple question

Status
Not open for further replies.

Scunningham99

Programmer
Joined
Sep 20, 2001
Messages
815
Location
GB
i am trying to get ping command in script to work. i wish to test the result either 1 or 0 for success.

However whenever i try and put the command in ` ` it does not understand. the host i am trying to ping is called oracle.

neither work

#!/bin/ksh

test `ping oracle`

echo $1

or -----------------------------------------------

#!/bin/ksh

[`ping oracle`]

echo $1

ping oracle works fine, however i want to test he condition. Does anyone know where i am going wrong!!

Any help would be greatly appreciated..

Sy
 
Sy, you should be using $? rather than $1 to test the result.
 
.....and test the result, rather than your command, ie:

ping oracle
result=$?

if [ result = 1 ]
then
echo 'ping failed'
else
echo 'ping succeeded'
fi

Might work?
 
cheers typo dont know ehy i was using a 1...

thanks for ur help ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top