The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
finger felixwhoals UNIX for Dummies Questions & Answers 2 12-18-2007 08:35 AM
Extracting specific info from finger command franny UNIX for Dummies Questions & Answers 1 12-05-2007 09:13 AM
help in finger command. shanshine Shell Programming and Scripting 1 06-06-2007 08:10 AM
How to input username on text file into finger command on shell script Micz Shell Programming and Scripting 3 11-07-2005 10:38 PM
Using the Finger command in a Script apolishuk Shell Programming and Scripting 4 12-02-2003 10:42 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-10-2006
Registered User
 

Join Date: Feb 2005
Location: Canada
Posts: 131
Stumble this Post!
finger command

Hello all,

Here is what I am trying to do. If a user exist, then send an echo "EXIST" or else "DOES NOT EXIST". (under HP-UX)

Kind of:

Code:
#!/usr/bin/sh
USER=mylogin

finger $USER

if $? = 0
then
     echo "EXIST""
else
     echo "DOES NOT EXIST"
fi

Does not work at all. Any idea?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 11-10-2006
Registered User
 

Join Date: Feb 2005
Posts: 52
Stumble this Post!
I have no access to HP-UX and finger is not present in my system.
But I would try "who" piped to "grep" for this purpose.
Reply With Quote
  #3 (permalink)  
Old 11-10-2006
Registered User
 

Join Date: Feb 2005
Posts: 52
Stumble this Post!
Quote:
Code:
if $? = 0
Does not work at all.
It should be
Code:
if [ $? -eq 0 ];
Reply With Quote
  #4 (permalink)  
Old 11-11-2006
kamitsin's Avatar
Registered User
 

Join Date: Nov 2006
Location: /dev/null
Posts: 177
Stumble this Post!
Checked on HP-UX system

......................................
#!/usr/bin/sh
USER=mylogin

finger $USER > /dev/null ### Will not display the output of finger command

if [ $? -eq 0 ]
then
echo "EXIST""
else
echo "DOES NOT EXIST"
fi
........................................
Reply With Quote
  #5 (permalink)  
Old 11-11-2006
Tornado's Avatar
Registered User
 

Join Date: Nov 2006
Location: Melbourne
Posts: 240
Stumble this Post!
Finger is disabled on all our servers, just like talk, and rwall are.

You would be better of getting the info from the passwd file.
Reply With Quote
  #6 (permalink)  
Old 11-16-2006
Registered User
 

Join Date: Jan 2006
Posts: 43
Stumble this Post!
finger wont help as when I gave bogus username it still gave and o/p for $? as 0

Cheers,
Reply With Quote
  #7 (permalink)  
Old 11-21-2006
Registered User
 

Join Date: May 2006
Location: England
Posts: 257
Stumble this Post!
Try:

cat /etc/passwd | grep username 1>/dev/null 2>&1

if [ $? != 0 ]
then
echo user does not exist
else
echo user does exist
fi
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:53 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