It is currently Tue, 30 Nov 2021 17:42:20 GMT



 
Author Message
 Bourne shell script to determine users shell
All,

As root, I would like to get the shell and home directory of any user.
I know I can grep it out of /etc/passwd -OR- ypcat passwd but what if
the authentication is via ldap? What I am looking for is a
implementation similar to getpwent() system call.
Is it possible in bourne shell?
Please explain.

Chandrashekar Tippur



 Mon, 03 Sep 2007 05:32:54 GMT   
 Bourne shell script to determine users shell

getent passwd user

--
Michael Tosch
Mail: michael.tosch:hp.com



 Mon, 03 Sep 2007 05:44:49 GMT   
 Bourne shell script to determine users shell
On 2005-03-16 16:32:54 -0500, "Shekar" <ctip...@msn.com> said:

you can use "awk -F:" to separate out the fields in each line of the
password file. I believe that the users shell is the last field so you
could say:

    usr=`awk -F: '{print $1}'`
    shell=`awk -F: '{print $7}'`

    echo $usr "is using shell" $shell



 Thu, 06 Sep 2007 14:35:11 GMT   
 Bourne shell script to determine users shell

How about using a Unix tool that relieves you of the responsibility
of knowing the database format? E.g. 'finger'? Is your 'finger'
command LDAP-aware? Certainly it is /etc/passwd- and NIS-aware.

alexis$ finger alexis | sed -n 's/.*Shell: \([^ ]*\).*/\1/p' | uniq
/bin/bash
alexis$

How's that?

Alexis

http://habgood-everett.mysite.wanadoo-members.co.uk/index.html



 Thu, 06 Sep 2007 21:31:31 GMT   
 Bourne shell script to determine users shell

ITYM:    usr=`awk -F: '{print $1}' /etc/passwd`

What part of "I know I can grep it out of /etc/passwd -OR- ypcat passwd but
what if the authentication is via ldap?" are you having a problem with?

(Under Linux or Solaris - probably others) Take a look at "getent".



 Fri, 16 Nov 2007 22:17:46 GMT   
 
   [ 5 post ] 

Similar Threads

1. Bourne shell script affecting current shell with arguments

2. Light Speed Bourne Shell! (was: Bourne shell tricks)

3. Bourne Shell compatible shells (was: Request: which shells)

4. Determining if user is root in shell script

5. A Solaris 8 (Bourne Shell) Scripting question, regarding a log rotation script

6. help in learning how to do Bourne shell scripts then converting them to csh scripts

7. Determining full path of shell script in script

8. getting environment variables from c shell using Bourne shell


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software