Computing.Net > Forums > Unix > how to write a shellscript sleep

how to write a shellscript sleep

Reply to Message Icon

Original Message
Name: eric_g
Date: September 6, 2003 at 08:04:25 Pacific
Subject: how to write a shellscript sleep
OS: unix
CPU/Ram: 2828
Comment:

how to write a shellscript which can do that.
That display on the screen
-how many user logged in
-newlogins since last sample
-who has logged out since las sample
-how many processe started since last sample.
When killed
-report long it the script run
-report how many time the script have run
- how many login and logout in the priod
- remove all temporay files used


Report Offensive Message For Removal


Response Number 1
Name: David Perry
Date: September 6, 2003 at 11:45:10 Pacific
Subject: how to write a shellscript sleep
Reply: (edit)

Please post what you have done so far and questions about the trouble spots. Don't expect someone else to do your homework.

man who
man last
man rm
man acct


Report Offensive Follow Up For Removal

Response Number 2
Name: eric_g
Date: September 8, 2003 at 04:57:31 Pacific
Subject: how to write a shellscript sleep
Reply: (edit)

Dear David

could tell me how the write the command to display the who log out. please thank


Report Offensive Follow Up For Removal

Response Number 3
Name: David Perry
Date: September 8, 2003 at 05:16:45 Pacific
Subject: how to write a shellscript sleep
Reply: (edit)

write the output of who to a file

who > /tmp/who.out

When the script is run again, move the last sample so it is not overwritten

if [ -f /tmp/who.out ] ; then
mv /tmp/who.out /tmp/who.tmp
who > /tmp/who.out
diff who.tmp who.out | awk '// { print $1 }'
else
echo "No previous who sample.
fi


Report Offensive Follow Up For Removal

Response Number 4
Name: eric_g
Date: September 8, 2003 at 05:42:47 Pacific
Subject: how to write a shellscript sleep
Reply: (edit)

hi David
here i do a shell script that is to display the how many log in and out. But when i run is they display error message. could fix it for me and i want to display only number of people that log in and out. i don't wan't the whole listed. thank you very very much for your Help.

$cat watchwho
#whatwho: watch who log in and out

new=/tmp/wwho1.$$
old=/tmp/wwho2.$$
>$old

while:
do
who >$new
diff $old $new
mv $new $old
sleep 60
done| awk '/>/ {$1 = "in: ":print}
/>/ {$1 = "out: ":print}'


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: how to write a shellscript  sleep

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge