- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script question
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
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
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
09-18-2002 08:12 AM
09-18-2002 08:12 AM
script question
I have this script here that I ran every so often to ping my connections. How do I use the grep statement and have it grep for 100% packetloss and then display just the packet loss info. to the screen. I hope I'm making clear what I'm asking for here. Points will definitely be assigned.
host=$(hostname)
case $host in
"hostname")
echo "PINGING FROM $host"
/etc/ping hostname -n 3
/etc/ping 192.168.22.36 -n 3
/etc/ping 192.168.24.36 -n 3
/etc/ping 192.168.22.34 -n 3
/etc/ping 192.168.24.34 -n 3
echo "PINGING TO POPS"
/etc/ping 192.159.81.20 -n 3
;;
* ) echo "$host not in list"; exit 1;;
esac
exit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 08:15 AM
09-18-2002 08:15 AM
Re: script question
You may have to adapt for the %
Jean-Luc
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x64a193e260b0d611abdb0090277a778c,00.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 08:16 AM
09-18-2002 08:16 AM
Re: script question
I know you are looking for an answer with grep, but you can do it without grep'ing the result. You can just test the result of the ping in an if statement and go from there. Here is a thread with a similar script:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xfbf35f260cafd4118fef0090279cd0f9,00.html
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 08:19 AM
09-18-2002 08:19 AM
Re: script question
case $host in
"hostname")
echo "PINGING FROM $host"
(/etc/ping hostname -n 3
/etc/ping 192.168.22.36 -n 3
/etc/ping 192.168.24.36 -n 3
/etc/ping 192.168.22.34 -n 3
/etc/ping 192.168.24.34 -n 3
echo "PINGING TO POPS"
/etc/ping 192.159.81.20 -n 3) | grep "100% packet loss"
;;
* ) echo "$host not in list"; exit 1;;
esac
exit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 10:53 AM
09-18-2002 10:53 AM
Re: script question
#/usr/bin/sh
#for addr in hostname 192.168.22.36 192.168.24.36 192.168.22.34 192.168.24.34
do
stat=`/usr/sbin/ping $addr -n 3 | grep "100% packet loss"`
if [ $? -eq 0 ]
then
echo $addr: $stat
fi
# Alternate method since I've read that $? may be set by ping on 10.20
# to 0 regardless of whether it succeeds or fails
if [ X"$stat" != X ]
then
echo $addr: $stat
fi
done
Darrell