Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with shell script

Status
Not open for further replies.

aiquyen

Technical User
Mar 25, 2003
8
0
0
US
Good afternoon,
I need to create a Bourne shell script to have a pop up message display user's history every time they log in my system. The pop up message will tell my users when were the last time they log in. How many time their log were failed before success to log in the system). How can I start with the script.

Please help me.



 
On many UNIX systems some of this information is already displayed, for example:

Solaris:

[tt]Last login: Wed Mar 26 13:16:15 from (hostname)[/tt]

SCO OpenServer:

[tt]Last successful login for (username): Wed Mar 26 13:37:37 2003 on ttyp0
Last unsuccessful login for (username): Tue Mar 25 18:02:00 2003 on ttyp0[/tt]

Linux:

[tt]Last login: Wed Mar 12 15:59:06 2003 from (hostname)[/tt]

Does yours not do this? I'm not sure how you would determine the number of failed logins before they logged in successfully. Annihilannic.
 
If you want more than just the very last, you could do something along these lines. (I'm sure there's probably a more stylish way)

Code:
USER=`id | awk -F\( '{print $2}' | awk -F\) '{print $1}'`
last | egrep '^$USER\ ' | head -5

This would show the last 5 logins. --
Andy
 
The more stylish way...
[tt]
last -5 $LOGNAME [/tt]
 
Thank you for all of your helps.

AQ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top