1845821 Members
3556 Online
110250 Solutions
New Discussion

Shell script qustion

 
SOLVED
Go to solution
mvr
Regular Advisor

Shell script qustion

I know "this is not good idea", but I still have to do this.
I need to add the workstation in the /etc/passwd (using the useradd command) and then I have to edit the same user.
This is what I'm talking about:
after adding the new user (workstation) I have this entry in the /etc/passwd

wsat1221:*:284:102:,,,,:/baan/bse/home/wgr:/sbin/sh

and I need to change in to these
wsat1221$:*:284:102:,,,,:/dev/null:/bin/false

Note $ in the end of the user name as well as home directory and the shell

Thank you,

Miro
4 REPLIES 4
mvr
Regular Advisor

Re: Shell script qustion

This is what I came up so far with .... (attached)
Dietmar Konermann
Honored Contributor

Re: Shell script qustion

Pure shell idea:

while IFS=: read user pw uid gid text home shell
do
[[ $user = wsat1221 ]] && user=wsat1221\$
echo "$user\$:$pw:$uid:$gid:$text:$home:$shell"
done
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
Dietmar Konermann
Honored Contributor

Re: Shell script qustion

Oops... forgor the home dir and the shell.

while IFS=: read user pw uid gid text home shell
do
[[ $user = wsat1221 ]] && user=wsat1221\$
echo "$user\$:$pw:$uid:$gid:$text:/dev/null:/bin/false"
done
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
Dietmar Konermann
Honored Contributor
Solution

Re: Shell script qustion

Wasn't my day, today. Will go home now. :( Sorry.

while IFS=: read user pw uid gid text home shell
do
if [[ $user = wsat1221 ]]; then
user=wsat1221\$
home=/dev/null
shell=/bin/false
fi
echo "$user\$:$pw:$uid:$gid:$text:$home:$shell"
done
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)