- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: HP-UX Script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 12:15 AM
11-26-2002 12:15 AM
I just wrote some script in HP-UX regarding the ECHO ping.
when I execute a command
IP="202.202.202.202 (example)
and then
/usr/sbin/ping $IP -n 1 |wc -c
a return value is 226.
so when I change the IP to a fake IP let say IP=202.202.202.203 and I execute a command
/usr/sbin/ping $IP -n 1 |wc -c
a return value is 135.
After tht I execute a same command with real IP so I get return value is 230.
So my question i how can I put a two condition where are if return values is 226 OR 230 so a retval=1. My example script
IP="202.202.202.202"
CONTACT=$(/usr/sbin/ping $IP -n 1 | wc -c)
if [ "$CONTACT" -eq 226 ]
then
retval=0
else
retval=1
fi
echo "Destination Status" $retval
return retval
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 12:23 AM
11-26-2002 12:23 AM
SolutionTry :
CONTACT=$(/usr/sbin/ping $IP -n 1 | wc -c)
if [ "$CONTACT" -eq 226 -o "$CONTACT" -eq 230 ]
then
retval=0
else
retval=1
fi
echo "Destination Status" $retval
return retval
Then you will have retval = 0 for CONTACT = 226 OR 230.
Regards,
Fr??d??ric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 12:28 AM
11-26-2002 12:28 AM
Re: HP-UX Script
CONTACT=$(/usr/sbin/ping $IP -n 1 | wc -c)
if [ "$CONTACT" -eq 226 -o "$CONTACT" -eq 230 ]
then
retval=0
else
retval=1
fi
echo "Destination Status" $retval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 12:42 AM
11-26-2002 12:42 AM
Re: HP-UX Script
for a limited number of return values, you could make use of a case-structure, e.g.:
case $CONTACT in
226) retval=0;;
230) retval=0;;
*) retval=1;;
esac
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 12:48 AM
11-26-2002 12:48 AM
Re: HP-UX Script
If you are looking for a script to monitor the network
check this
#!/bin/sh
IP="202.202.202.202"
CONTACT=$(/usr/sbin/ping $IP -n 1 |tail -2 |grep "%" |tail -1 |awk -F"," '{print $3}'|awk -F"%" '{print $1}')
if [ "$CONTACT" -lt 100 ]
then
echo "LINK UP"
else
echo "LINK Down"
fi
-Niraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 12:52 AM
11-26-2002 12:52 AM
Re: HP-UX Script
Thanks everyone.
My problem resolves.
AZLY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 12:53 AM
11-26-2002 12:53 AM
Re: HP-UX Script
What about...
ping $IP -n 1 | grep -q "bytes from"
retval=$?
echo "Destination Status" $retval
return retval
Best regards...
Dietmar.