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


shell program

Posted on 2000-04-23
Medium Priority
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.
Question by:sriram_bandi

Expert Comment

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.


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

Author Comment

ID: 2746019
it's not a incremental who

Accepted Solution

etdey earned 100 total points
ID: 2746288
# 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 "-----------------------------"
  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

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

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 ;-)


Expert Comment

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. :-)
LVL 21

Expert Comment

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


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