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