![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bourne: How to invoke an alias from within a shell script | techshots | Shell Programming and Scripting | 2 | 06-04-2006 12:38 AM |
| cd from a Bourne Shell Script - Please Help | fawqati | Shell Programming and Scripting | 10 | 05-25-2006 03:26 AM |
| Bourne Shell Script | dmhonor914 | UNIX for Dummies Questions & Answers | 2 | 12-10-2003 12:25 PM |
| bourne shell script | psrinivas | Shell Programming and Scripting | 2 | 12-06-2001 03:38 PM |
| Bourne shell script need help please ? | dezithug | UNIX for Advanced & Expert Users | 7 | 10-24-2001 01:59 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Bourne Shell script - log for users logging on and off
Hello all, I'm new to shell scripting and want to make a script that I can write to log the users logging on and off the a unix system.
I have had a good look over the past few days to crack it, I think I am getting close. I want a script that runs an infinite loop to check every 5 seconds to report on who logs into and who logs out of the unix system. This is a example of the output I would like: PHP Code:
who | awk '{print $1}' | sort > temp1 to get the users logged on and saving that into a temp file. and have a while loop set up like this which will run each 5 seconds. while true do . . . . . sleep 5 done The problem I'm having is, I can't work out how to compare the current users logged in to the users that have previously logged in. I thought of making a second temp file that stores the current users then using: cmp temp1 temp2 to look at the difference. problem is it gives me an output saying "file differs at character 42, line 6" and that isn't helping me much as I would like to then display that users name but not sure how to print that position in the file (or just a line for that matter). The test to see if the user has logged on or off is easy, as it is only a couple of if statements. like if user is in temp1 but not in temp2 then the user has logged out and vice versa. I have been looking at this for a while now and am going around in circles. any code fragments, help or written shell scripts would be greatly appreciated.Thanks in advance Noodle Last edited by noodlesoup; 09-08-2006 at 05:34 AM.. |
|
||||
|
you are quite the life saver, thank you very much.
Also is there a quick command you can use for a an if statement to see if the files differ? if [statement here]. I had a look at the cmp utility and the exit status was 0 is the files were identical and 1 if the files were diferent. but I couldn't get the exit status printed to screen. Thanks in advance |
|
||||
|
OK, this is what I have got now, not srue where I have gone wrong. it says I have a syntax error on line 30; ';;' unexpected? any ideas? I thought these were needed for the case to work
PHP Code:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|