Hallo, ich habe ein Skript geschrieben, das per useradd einen user hinzufügt und dann sofort danach passwd aufruft, um ein Passwort zu setzen. Das Skript sieht so ähnlich aus: ////////////////////////////////////////////////////////////// read usrComment read usrName returnValue=$(useradd -g users -c "$usrComment" -m "$usrName") if [ ! -z $returnValue ]; then echo "Beim Anlegen des neuen Users $usrName ist ein Fehler aufgetreten!" echo "Möglicherweise existiert der User bereits oder es wurden fehlerhafte" echo "Angaben eingegeben!" echo "--> Kein User angelegt! - Skript-Abbruch!" echo exit #1; fi echo "--> Der User $usrName wurde erfolgreich angelegt." echo "--> Sein Home-Verzeichnis lautet: /home/$usrName" echo echo "Bitte geben Sie das Passwort für den User $usrName ein:" echo "(Aus Sicherheitsgründen muss das Passwort zwei mal eingegeben werden)" passwd $usrName ////////////////////////////////////////////////////////////// Oft passiert es, dass passwd sagt, dass der user $usrName nicht existiert, OBWOHL er 100%ig angelegt worden ist ! Woran liegt das? Ich brauche unbedingt eine Lösung :-) Gruß, Dominik
* Dominik Haumann schrieb am 16.Sep.2001:
Das Skript sieht so ähnlich aus: ////////////////////////////////////////////////////////////// read usrComment read usrName
returnValue=$(useradd -g users -c "$usrComment" -m "$usrName")
if [ ! -z $returnValue ]; then echo "Beim Anlegen des neuen Users $usrName ist ein Fehler aufgetreten!" echo "Möglicherweise existiert der User bereits oder es wurden fehlerhafte" echo "Angaben eingegeben!" echo "--> Kein User angelegt! - Skript-Abbruch!" echo exit #1; fi
Warum so kompliziert? if ! useradd -g users -c "$usrComment" -m "$usrName"; then echo ... ... exit 1 fi tut's doch auch. Abgesehen davon gibt useradd doch selber eine Fehlermeldung aus, oder?
echo "--> Der User $usrName wurde erfolgreich angelegt." echo "--> Sein Home-Verzeichnis lautet: /home/$usrName" echo echo "Bitte geben Sie das Passwort für den User $usrName ein:" echo "(Aus Sicherheitsgründen muss das Passwort zwei mal eingegeben werden)" passwd $usrName //////////////////////////////////////////////////////////////
Oft passiert es, dass passwd sagt, dass der user $usrName nicht existiert, OBWOHL er 100%ig angelegt worden ist !
Woran liegt das?
Keine Ahnung, kann mir vorstellen, daß useradd verschiedene Prozesse im Background ablaufen läßt, die dann noch nicht fertig sind. Wenn Du es anschließend überprüft sind sie es. Vielleicht hilft ein sleep 3, oder so.
Ich brauche unbedingt eine Lösung :-)
Was soll ich dazu sagen? Bernd -- ACK = ACKnowledge = Zustimmung | NAC = No ACknowledge = keine Zustimmung DAU = Dümmster Anzunehmender User | LOL = Laughing Out Loud = Lautes Lachen IIRC = If I Remember Correctly = Falls ich mich richtig erinnere OT = Off Topic = Am Thema (der Liste) vorbei |Zufallssignatur 11
Am Sonntag, 16. September 2001 16:45 schrieben Sie:
* Dominik Haumann schrieb am 16.Sep.2001:
Das Skript sieht so ähnlich aus: ////////////////////////////////////////////////////////////// read usrComment read usrName
returnValue=$(useradd -g users -c "$usrComment" -m "$usrName")
if [ ! -z $returnValue ]; then echo "Beim Anlegen des neuen Users $usrName ist ein Fehler aufgetreten!" echo "Möglicherweise existiert der User bereits oder es wurden fehlerhafte" echo "Angaben eingegeben!" echo "--> Kein User angelegt! - Skript-Abbruch!" echo exit #1; fi
Warum so kompliziert?
if ! useradd -g users -c "$usrComment" -m "$usrName"; then echo ... ... exit 1 fi
tut's doch auch. Abgesehen davon gibt useradd doch selber eine Fehlermeldung aus, oder?
echo "--> Der User $usrName wurde erfolgreich angelegt." echo "--> Sein Home-Verzeichnis lautet: /home/$usrName" echo echo "Bitte geben Sie das Passwort für den User $usrName ein:" echo "(Aus Sicherheitsgründen muss das Passwort zwei mal eingegeben werden)" passwd $usrName //////////////////////////////////////////////////////////////
Oft passiert es, dass passwd sagt, dass der user $usrName nicht existiert, OBWOHL er 100%ig angelegt worden ist !
Woran liegt das?
Keine Ahnung, kann mir vorstellen, daß useradd verschiedene Prozesse im Background ablaufen läßt, die dann noch nicht fertig sind. Wenn Du es anschließend überprüft sind sie es.
Vielleicht hilft ein sleep 3, oder so. Manchmal tuts ein sleep 3, aber selbst sleep 20 bringt manchmal nix!
Ich brauche unbedingt eine Lösung :-)
Was soll ich dazu sagen?
Bernd
Hallo, * On Sun, Sep 16, 2001 at 05:21 PM (+0200), Dominik Haumann wrote:
Manchmal tuts ein sleep 3, aber selbst sleep 20 bringt manchmal nix!
Vielleicht ist ein laufender (und u.U. falsch konfigurierter bzw. nicht angepasster) "nscd" daran Schuld, dass der neu eingerichtete Benutzer noch nicht systemweit bekannt ist? Gruss, Steffen
participants (3)
-
B.Brodesser@t-online.de
-
Dominik Haumann
-
Steffen Moser