Q : Use shell variable to assign the password

Q : Use shell variable to assign the password

Post by skon lapamnuaypo » Wed, 25 Feb 1998 04:00:00



I want to write a script that can re-assign a new password for Unix
users. For example :

cat /tmp/usrlist | while read user newpasswd
do
   echo "$newpasswd" | passwd $user
done

The script above is not work because  passwd command always prompt for
password on screen.

I will very appreciated,if you can make a copy of your answering to my

Thanks
Skon L

 
 
 

Q : Use shell variable to assign the password

Post by Juergen Hein » Thu, 26 Feb 1998 04:00:00



>I want to write a script that can re-assign a new password for Unix
>users. For example :

>cat /tmp/usrlist | while read user newpasswd
>do
>   echo "$newpasswd" | passwd $user
>done

Correct me, but you'll need expect at least to do something like that,
since passwd ( and getpass(3) if available ) both use /dev/tty to
read from, not stdin.

Bye, Juergen

--
\ Real name     : Juergen Heinzl     \       no flames      /

  \ Phone Private : +49 911-4501186    \                  /

 
 
 

Q : Use shell variable to assign the password

Post by Glenn Wes » Thu, 26 Feb 1998 04:00:00



> I want to write a script that can re-assign a new password for Unix
> users. For example :

> cat /tmp/usrlist | while read user newpasswd
> do
>    echo "$newpasswd" | passwd $user
> done

> The script above is not work because  passwd command always prompt for
> password on screen.

Because passwd gets input from /dev/tty NOT stdin as you expected.  I
have heard that a utility called Expect may do what you want...

> I will very appreciated,if you can make a copy of your answering to my