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!

Need help creating ksh script

Status
Not open for further replies.

sjcrane

MIS
Jan 18, 2006
41
US
I want to monitor a netstat command as follows:

# netstat -Aan|grep 4800|grep LISTEN
f1000e0017a12bb8 tcp4 0 0 *.4800 *.* LISTEN

So I want the script to run this and if there is a return of "LISTEN" do nothing..

If it returns nothing email alert to recipients.

So if:

# netstat -Aan|grep 4800|grep LISTEN
f1000e0017a12bb8 tcp4 0 0 *.4800 *.* LISTEN (Do Nothing)
#

#netstat -Aan|grep 4800|grep LISTEN (email recipients)
#

Any help would be appreciated...
 
Hello sjcrane,

this should help you:

Code:
#!/usr/bin/ksh

netstat -an | grep 4800 | grep LISTEN > /dev/null

if [ $? -ne 0 ];
then
echo "Mailbody" | mail -s "Mailheader" recipients
fi


Regards,
Thomas

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top