Password
Hvorfor kan jeg ikke få denne linie til at virker, hvis den bliver gentaget flere gange efter hinanden: passthru(\"echo $passw|passwd --stdin $user\");Hvis jeg vil ændre 5 passwords, ser det nogenlunde sådan ud:
[root@knud /root]# php useradd.php
sh: -c: line 2: syntax error near unexpected token `|p\'
sh: -c: line 2: `|passwd --stdin test1\'
X-Powered-By: PHP/4.0.1pl2
Content-type: text/html
vir1password
sh: -c: line 2: syntax error near unexpected token `|p\'
sh: -c: line 2: `|passwd --stdin test2\'
vir2password
sh: -c: line 2: syntax error near unexpected token `|p\'
sh: -c: line 2: `|passwd --stdin test3\'
vir3password
sh: -c: line 2: syntax error near unexpected token `|p\'
sh: -c: line 2: `|passwd --stdin test4\'
vir4password
Changing password for user test5
passwd: all authentication tokens updated successfully
Her er et snip fra koden:
while(!feof($f)) {
$line=@fgets($f,1024);
if (strlen($line)>5) {
list($user,$passw)=explode(\"§\",$line);
passthru(\"useradd $user &\");
sleep(5);
passthru(\"echo $passw|passwd --stdin $user\");
}
}
fclose($f);
Jeg vil også være taknemlig for en perl løsning, til at oprette brugere samt password + ændre password.
