Changement de mot de passe en script shell (mode raw).
From Tuxunix
2 solutions existes :
- Avec expect (module a ajouter/compiler sous GNU/Linux et AIX)
- Avec chpasswd (commande existante sous GNU/Linux et AIX version >= a 5.2)
EXPECT
1.#!/bin/sh 2. 3.USER=titi 4.PWD=toto 5. 6.cat <<EOF | expect -f - "$USER" "$PWD" 7.spawn passwd [lindex \$argv 0] 8.set password [lindex \$argv 1] 9.expect "Enter new UNIX password:" 10.send "\$password\r" 11.expect "Retype new UNIX password:" 12.send "\$password\r" 13.send "\r" 14.expect eof 15.EOF
CHPASSWD
1.#!/bin/sh 2. 3.USER=`titi` 4.PWD=`toto` 5.( echo $USER:$PWD ) | chpasswd >/dev/null 2>&1

