Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

shell program

Posted on 2000-04-23
6
Medium Priority
?
346 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
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 100 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

972 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