nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

shell script to send mail for each login.

This is a discussion on shell script to send mail for each login. within the Shell scripting forums, part of the Development/Scripting category; Hi Everybody, Recently i wrote a script to send mail for each login to my server, as i wanted to ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 27-11-2007, 11:13 AM
Junior Member
User
 
Join Date: Nov 2007
OS: RedHat Linux 4
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
ephdia is on a distinguished road
Lightbulb shell script to send mail for each login.

Hi Everybody,
Recently i wrote a script to send mail for each login to my server,
as i wanted to send mail at the moment of every login i put this script to /root/.bashrc
and it is sending mail only for root logins.now,the problem raisen that i couldn't use scp with this servers.
i don't know is the script correct or not.Please help me to find out the cause of the problem....or any other script to make it work effectively.....Please help...


&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&
#!/bin/bash
echo `last $i | head -1 | awk '{print $1" "$3" "$4" "$5" "$6" "$7}'`|while read output;
do
echo $output
ip=$(echo $output | awk '{print $2}' )
on=$(echo $output | awk '{print $3" "$4" "$5}' )
at=$(echo $output | awk '{print $6'} )
echo "User logged in to $(hostname) server from $ip on $on at $at"|mail -s "Alert from server $(hostname)" xxxx@example.com
done
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&


Thanks in advance.,
Ephdia
Reply With Quote
  #2 (permalink)  
Old 27-11-2007, 04:38 PM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
OS: Debian GNU/Linux
Posts: 506
Thanks: 0
Thanked 8 Times in 6 Posts
Rep Power: 7
monk has a spectacular aura about monk has a spectacular aura about
Default

So you want script that can email when user login via scp?
__________________
May the force with you!
Reply With Quote
  #3 (permalink)  
Old 27-11-2007, 04:42 PM
Junior Member
User
 
Join Date: Nov 2007
OS: RedHat Linux 4
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
ephdia is on a distinguished road
Lightbulb

I would like to know whether is the script correct one? and solution to use my scp as normal.

Thanks,
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Script to monitor a particular directory and send out e-mail.... nageshms Shell scripting 1 11-02-2008 02:01 PM
shell scripting + send mail with header ephdia Shell scripting 0 27-11-2007 11:29 AM
send mail installation and configuration jhn_daz@yahoo.com Mail Servers 1 01-11-2007 09:37 AM
send mail attachment solaris K.R. Solaris/OpenSolaris 1 01-02-2007 07:05 PM
Require Shell Script Which sends all server info on mail puppen Linux software 3 25-10-2006 08:07 PM


All times are GMT +5.5. The time now is 07:00 AM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38