Solved

shell program

Posted on 2000-04-23
6
324 Views
Last Modified: 2010-04-21
write a shell program(boune shell) on the following topic.

watching all people logging in and out and report as people come and go- a sort of incremental who. also display statistics of people logged in and logged out every 2 minutes.
0
Comment
Question by:sriram_bandi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Expert Comment

by:festive
ID: 2742966
well you could do the following:
tail -f /var/log/syslog

this will give you a complete running log and some other usefull info.

alternatively:

#!/bin/sh -p
while true; do
    who
    sleep 120
done >> /usr/local/logs/userlog.log
0
 

Author Comment

by:sriram_bandi
ID: 2746019
it's not a incremental who
0
 

Accepted Solution

by:
etdey earned 50 total points
ID: 2746288
#!/bin/sh
#
# watch_logins.sh
#

last | grep -v "still logged in" > /tmp/last.off.log0
last | grep    "still logged in" > /tmp/last.on.log0

echo "First cycle is empty..."

while [ 1 ]; do

  last | grep -v "still logged in" > /tmp/last.off.log1
  last | grep    "still logged in" > /tmp/last.on.log1

  echo "-----------------------------"
  date
  echo "-----------------------------"

  echo "Logins:"
  echo "-------"
  diff /tmp/last.on.log0  /tmp/last.on.log1 | egrep '^> '

  echo ""

  echo "Logoffs:"
  echo "--------"
  diff /tmp/last.off.log0  /tmp/last.off.log1 | egrep '^> '

  echo ""

  mv /tmp/last.off.log1 /tmp/last.off.log0
  mv /tmp/last.on.log1 /tmp/last.on.log0

  sleep 120

done
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 21

Expert Comment

by:tfewster
ID: 2747933
This guy seems a bit smarter than the last person who asked for the answers on this homework assignment a couple of months ago:
- He's split the paper into 2 questions, rather than ask them all together
- He's not asked the "Test if a string is a palindrome" question, so I guess he's worked it out himself ;-)

0
 
LVL 2

Expert Comment

by:festive
ID: 2750848
agreed, interesting comment , first he says that he wants "a sort of incremental who", then he rejects two ways of achieving it, admittedly the who was cheap and nasty, But so is someone cheating on their homework. :-)
0
 
LVL 21

Expert Comment

by:tfewster
ID: 2759881
I see the palindrome question HAS been posted now :-)

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question