Computing.Net > Forums > Unix > Login script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Login script

Reply to Message Icon

Name: Dinesh Prakash
Date: June 16, 2002 at 20:31:35 Pacific
Comment:

Need to write a shell script which gives a message to the adminitrator/root via email or by message on the console, whenever a user logs on to the system. Can anyone suggest as to how I go about doing this ??



Sponsored Link
Ads by Google

Response Number 1
Name: LANkrypt0
Date: June 17, 2002 at 07:16:26 Pacific
Reply:

Pretty simple either

echo "message goes here | write root

or

echo "message goes here" | mail -s "subject" e-"mailaddress"


0

Response Number 2
Name: LANkrypt0
Date: June 17, 2002 at 07:22:48 Pacific
Reply:

OPS :) The first one should be
echo "Message Goes Here" | write root

FOrgot the closing quote.


0

Response Number 3
Name: frank
Date: June 17, 2002 at 08:37:16 Pacific
Reply:

dinesh,

the script from LANkrypt0 is ok, you should place it under /etc/profile {which will be executed for every user logged in via telnet}.
This does not include an FTP loggin or graphical loggin.
But also this is possible do you would like to know how ?


No RISK no fun

Regards Frank


0

Response Number 4
Name: Muks
Date: June 17, 2002 at 09:28:25 Pacific
Reply:

Hi frank...would it work for ssh also? And
id like to know what needs to be done for
graphical or FTP logins.

thanks

mux


0

Response Number 5
Name: Dinesh
Date: June 17, 2002 at 22:00:45 Pacific
Reply:

Hi Frank & LANkrypt0,
I wanted to know if one can read the sylog file to determine the user log in information and email or notify the root about the user who has logged in.

like tail -f syslog | grep telnetd and then finding the user who logged in and then sending an email.

Can you help me regarding this ...


0

Related Posts

See More



Response Number 6
Name: frank
Date: June 18, 2002 at 01:02:49 Pacific
Reply:

mux,

the default configuration of ssh uses also /etc/profile.
But in the end it depends on the detail configuration of your ssh.

mux & Dinesh,

to see other loggins like PCNFS, FTP, XTERM,
you can use the last command grep for the interested time slice and send the resault to root.
e.g.
SearchDate=`date +"%b %d"`
last |grep "$SearchDate"|awk '{system (" echo login: " $1 " at " $4,$5,$6 ) } '

put this lines into a script which will executet in your requierd time slice (once a day ?)

or if you would like to have a kind of real time monitoring use the following as a script (is a endless loop):

Luser=`last | head -1`
Vuser=$Luser
while :
do
Luser=`last | head -1`
if [ "${Luser}" != "${Vuser}" ]
then
echo $Luser > /tmp/mytmp
mail a1xrdb1@cipofdc1 < /tmp/mytmp
Vuser=$Luser
fi
done


You can modify the script to use the syslog file also very quick.

Have Fun
Frank


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Login script

login script www.computing.net/answers/unix/login-script/2850.html

Unix login through DOS telnet!!!! www.computing.net/answers/unix/unix-login-through-dos-telnet/1019.html

Korn shell script doubt ??? www.computing.net/answers/unix/korn-shell-script-doubt-/3407.html