Solved

shell program

Posted on 2000-04-23
6
303 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
Comment Utility
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
Comment Utility
it's not a incremental who
0
 

Accepted Solution

by:
etdey earned 50 total points
Comment Utility
#!/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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 20

Expert Comment

by:tfewster
Comment Utility
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
Comment Utility
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 20

Expert Comment

by:tfewster
Comment Utility
I see the palindrome question HAS been posted now :-)

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
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 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…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now