The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
user logged on any server NIMISH AGARWAL UNIX and Linux Applications 3 09-28-2007 07:26 AM
know who logged and logged out with their timings vkandati UNIX for Dummies Questions & Answers 3 03-09-2005 06:04 AM
user logged on? provo Shell Programming and Scripting 1 12-08-2001 12:25 PM
Is user logged on?? provo UNIX for Dummies Questions & Answers 1 12-07-2001 01:41 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-29-2008
Registered User
 

Join Date: Apr 2008
Posts: 8
script on user who logged in????

writing a script that will check every 5 seconds whether a particular user has
logged into the system

Code:
# Determine if someone is logged on
# Version 4.0
if [ “$#” ne
1 ]
then
echo “ Incorrect number of arguments”
echo “Usage: $ ison4 <user>”
else
user=“$1”
if who | grep “$user” > /dev/null
then
echo “$user is logged on”
else
echo “$user is not logged on”
fi
fi
is this ok

Last edited by Yogesh Sawant; 04-30-2008 at 02:27 AM. Reason: added code tags
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-30-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 2,707
I don't see the loop and the "sleep 5" but as the body of that missing loop, this looks okay (though mind-numbingly verbose -- I guess you want to take out the "is not" case once you have made sure it works correctly).
Reply With Quote
  #3 (permalink)  
Old 04-30-2008
Part Time Moderator and Full Time Dad
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 755
how about converting this:
Code:
echo “Usage: $ ison4 <user>”
to:
Code:
echo “Usage: $0 username”
are you planning to run this script using watch ?
Reply With Quote
Google UNIX.COM
Reply

Tags
shell script, watch

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:12 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0