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 > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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 12:35 PM
Extracting specific info from finger command franny UNIX for Dummies Questions & Answers 1 12-05-2007 01:13 PM
help in finger command. shanshine Shell Programming and Scripting 1 06-06-2007 11:10 AM
How to input username on text file into finger command on shell script Micz Shell Programming and Scripting 3 11-08-2005 02:38 AM
Using the Finger command in a Script apolishuk Shell Programming and Scripting 4 12-02-2003 02:42 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-10-2006
qfwfq qfwfq is offline
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?
  #2 (permalink)  
Old 11-10-2006
odys odys is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 59
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.
  #3 (permalink)  
Old 11-10-2006
odys odys is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 59
Quote:
Code:
if $? = 0
Does not work at all.
It should be
Code:
if [ $? -eq 0 ];
  #4 (permalink)  
Old 11-11-2006
kamitsin's Avatar
kamitsin kamitsin is offline
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
........................................
  #5 (permalink)  
Old 11-11-2006
Tornado's Avatar
Tornado Tornado is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2006
Location: Melbourne
Posts: 249
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.
  #6 (permalink)  
Old 11-16-2006
nilesrex nilesrex is offline
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,
  #7 (permalink)  
Old 11-21-2006
johnf johnf is offline
Registered User
  
 

Join Date: May 2006
Location: England
Posts: 284
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
Sponsored Links
Closed Thread

Bookmarks

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 06:34 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