Register
It is currently Fri Dec 19, 2014 7:15 am

doing a command and email the results


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri Aug 06, 2010 5:28 pm   

Joined: Fri Aug 06, 2010 5:27 pm
Posts: 5
hello does anyone have any ideea how can i make a script to runn this command netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr and to email me the results of the command ?


Top
 Profile  
 PostPosted: Fri Aug 06, 2010 8:13 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 673
Location: Des Moines, Iowa
svann wrote:
hello does anyone have any ideea how can i make a script to runn this command netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr and to email me the results of the command ?



If you have mailx installed ...

Code:
!/bin/bash
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | mailx -s 'SUBJECT GOES HERE' -r 'REPLYTO@EMAIL.com' 'SENDTO@EMAIL.com'
exit 0


Or ......... instead of a script , that line could just be put in it's entirety into crontab, as a one line cronjob.

HTH's


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP