Hi, all -- I am trying to write a script in which I can add users and their samba passwords easily and quickly.? It looks something like: ?? useradd -c "User Name" -g groupname -p unixpassword accountname ?? echo -e "smbpassword\nsmbpassword\n" | pdbedit -a -t -u accountname If I type the lines from the keyboard, it works fine.? However, when I try to execute the script, the pdbedit on the second line reports that there's no unix accountname to apply to samba.? I assume that this is because the useradd process hasn't finished when the pdbedit is executed.? Is there a way to insure that the useradd has completed its execution before the pdbedit starts?? Alternatively is there a way to insert a delay between the two commands to allow the useradd to complete? Thanks. cheers, pete
On Fri, May 15, 2009 at 07:13:42AM -0700, Pete Clapham wrote:> Hi, all -- > > I am trying to write a script in which I can add users and their samba passwords easily and quickly.? It looks something like: > ?? useradd -c "User Name" -g groupname -p unixpassword accountname > > ?? echo -e "smbpassword\nsmbpassword\n" | pdbedit -a -t -u accountname > > If > I type the lines from the keyboard, it works fine.? However, when I try > to execute the script, the pdbedit on the second line reports that > there's no unix accountname to apply to samba.? I assume that this is > because the useradd process hasn't finished when the pdbedit is > executed.?nscd? Volker -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://lists.samba.org/archive/samba/attachments/20090515/3c2f0162/attachment.bin
Hello, useradd -c "User Name" -g groupname -p unixpassword accountname sleep 5s echo -e "smbpassword\nsmbpassword\n" | pdbedit -a -t -u accountname Did you want something like that? Regards, Michal PS I am using such a trick to make sure LDAP data is distributed among replicas, so that other distributed file servers have specified users when they ask for them... 2009/5/15 Pete Clapham <peteclapham@sbcglobal.net>:> Hi, all -- > > I am trying to write a script in which I can add users and their samba passwords easily and quickly.? It looks something like: > ?? useradd -c "User Name" -g groupname -p unixpassword accountname > > ?? echo -e "smbpassword\nsmbpassword\n" | pdbedit -a -t -u accountname > > If > I type the lines from the keyboard, it works fine.? However, when I try > to execute the script, the pdbedit on the second line reports that > there's no unix accountname to apply to samba.? I assume that this is > because the useradd process hasn't finished when the pdbedit is > executed. > > > Is there a way to insure that the useradd has completed its > execution before the pdbedit starts?? Alternatively is there a way to > insert a delay between the two commands to allow the useradd to > complete? > > Thanks. > > > cheers, > pete > -- > To unsubscribe from this list go to the following URL and read the > instructions: ?https://lists.samba.org/mailman/options/samba >
Hallo, Pete, Du meintest am 15.05.09:> I am trying to write a script in which I can add users and their > samba passwords easily and quickly.? It looks something like: ??> useradd -c "User Name" -g groupname -p unixpassword accountname> ?? echo -e "smbpassword\nsmbpassword\n" | pdbedit -a -t -u > accountname> If > I type the lines from the keyboard, it works fine.? However, when I > try to execute the script, the pdbedit on the second line reports > that there's no unix accountname to apply to samba.? I assume that > this is because the useradd process hasn't finished when the pdbedit > is executed.?Maybe - sometimes I put a "sleep 30" between these 2 lines. "sleep 10" wasn't always long enough. Strange. Nasty. Viele Gruesse! Helmut
On Fri, May 15, 2009 at 7:43 PM, Pete Clapham <peteclapham@sbcglobal.net> wrote:> Hi, all -- > > I am trying to write a script in which I can add users and their samba passwords easily and quickly.? It looks something like: > ?? useradd -c "User Name" -g groupname -p unixpassword accountname > > ?? echo -e "smbpassword\nsmbpassword\n" | pdbedit -a -t -u accountnameYou should evaluate the exit status of the previous command before going on to the next command, especially if there is a dependency. Evaluate the $? like if [ $? -eq 0 ]; then do_whatever fi> If > I type the lines from the keyboard, it works fine.? However, when I try > to execute the script, the pdbedit on the second line reports that > there's no unix accountname to apply to samba.? I assume that this is > because the useradd process hasn't finished when the pdbedit is > executed. > > > Is there a way to insure that the useradd has completed its > execution before the pdbedit starts?? Alternatively is there a way to > insert a delay between the two commands to allow the useradd to > complete? > > Thanks. > > > cheers, > pete > -- > To unsubscribe from this list go to the following URL and read the > instructions: ?https://lists.samba.org/mailman/options/samba