LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-27-2010, 01:08 AM   #1
saran_redhat
Member
 
Registered: May 2009
Location: chennai
Posts: 247

Rep: Reputation: 16
Need Scripts


HI Friends

I need one help. can anyone tel me how to make scripts using the following
command and the report send my mail id on daily basis.

w && echo "netstat listing" && netstat -nalp |grep ":22 "

last -a

zgrep ssh /var/log/secure* |grep Accept

zgrep ftp /var/log/secure* |grep Accept

I need all the report on daily basis. how to add scripts.

Please advise me.

Thanks
 
Old 10-27-2010, 01:20 AM   #2
Expeto
Member
 
Registered: Sep 2010
Posts: 30

Rep: Reputation: Disabled
Code:
w && echo "netstat listing" && netstat -nalp |grep ":22 " >> /tmp/report

last -a >> /tmp/report

zgrep ssh /var/log/secure* |grep Accept >> /tmp/report

zgrep ftp /var/log/secure* |grep Accept >> /tmp/report



mail -s 'Report!' email@domain.com < /tmp/report

rm /tmp/report

edit: you need to configure your mail server for this to work

Last edited by Expeto; 10-27-2010 at 01:24 AM.
 
Old 10-27-2010, 01:52 AM   #3
saran_redhat
Member
 
Registered: May 2009
Location: chennai
Posts: 247

Original Poster
Rep: Reputation: 16
scripts

Quote:
Originally Posted by Expeto View Post
Code:
w && echo "netstat listing" && netstat -nalp |grep ":22 " >> /tmp/report

last -a >> /tmp/report

zgrep ssh /var/log/secure* |grep Accept >> /tmp/report

zgrep ftp /var/log/secure* |grep Accept >> /tmp/report



mail -s 'Report!' email@domain.com < /tmp/report

rm /tmp/report

edit: you need to configure your mail server for this to work

Hi thanks for u r mail.
this is working fine. but i want this scripts for date basis. now report shows all details. my need is like today i run the scripts i will get get current date report.please advise me.
thanks sorr for my english
 
Old 10-27-2010, 04:42 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
One way is to include the date in your greps.

For example:
Code:
zgrep -E "^$(date +'%b %d').* ssh.*Accept" /var/log/secure*
Cheers,

Evo2.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling expect scripts from other expect scripts sevapopov Linux - Software 3 04-03-2008 10:33 PM
Hi help me in scripts rammu_sivraj Linux - Newbie 2 06-30-2006 12:18 PM
VPN: Debian Scripts -> Mandriva 2006 Scripts Undefined Mandriva 0 11-30-2005 01:10 PM
Need help running scripts from scripts sdouble Linux - Newbie 3 05-31-2004 01:56 PM
What scripts? whaase Linux - Newbie 6 11-14-2002 11:42 PM


All times are GMT -5. The time now is 06:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration