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 09:35 AM
Extracting specific info from finger command franny UNIX for Dummies Questions & Answers 1 12-05-2007 10: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 11:38 PM
Using the Finger command in a Script apolishuk Shell Programming and Scripting 4 12-02-2003 11:42 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-10-2006
Registered User
 

Join Date: Feb 2005
Location: Canada
Posts: 133
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  
Old 11-10-2006
Registered User
 

Join Date: Feb 2005
Posts: 53
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  
Old 11-10-2006
Registered User
 

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

Join Date: Nov 2006
Location: /dev/null
Posts: 177
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  
Old 11-11-2006
Tornado's Avatar
Registered User
 

Join Date: Nov 2006
Location: Melbourne
Posts: 243
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  
Old 11-16-2006
Registered User
 

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

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

Join Date: May 2006
Location: England
Posts: 265
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 Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:56 PM.


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

Content Relevant URLs by vBSEO 3.2.0