The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 10:26 AM
know who logged and logged out with their timings vkandati UNIX for Dummies Questions & Answers 3 03-09-2005 10:04 AM
user logged on? provo Shell Programming and Scripting 1 12-08-2001 04:25 PM
Is user logged on?? provo UNIX for Dummies Questions & Answers 1 12-07-2001 05:41 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-29-2008
kim187 kim187 is offline
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 05:27 AM.. Reason: added code tags
  #2 (permalink)  
Old 04-30-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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).
  #3 (permalink)  
Old 04-30-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
how about converting this:
Code:
echo “Usage: $ ison4 <user>”
to:
Code:
echo “Usage: $0 username”
are you planning to run this script using watch ?
Closed Thread

Bookmarks

Tags
shell script, watch

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0