Hi Steve, And thanks for your answer. Unfortunately it does not solve my problem. What I?m trying to do is to create two dirs using preexec in the same service. It works well as long as I?m only creating one directory, what I can?t figure out is how to create the second directory withing the same service. Eg. How would I continue after the last "fi" in the script to check for the second directory and create it if it does not exist? preexec = if [ ! -e /home/%U/dir1] then /bin/mkdir /home/%U/dir1; fi Robert Robert -- I've always had to use root preexec to create directories, even though the user seemingly has permission to create it. Here's my code to make [homes] refer to an smbhome below the home directory, thus protecting the . files from Wacky Windows users: [homes] read only=yes valid users=%U write list=%U root preexec=mkdir 0770 /home/%U/smbhome & chown %U:%U /home/%U/smbhome & path=/home/%U/smbhome browseable=no You'll notice I'm not as diligent as you about checking whether the directory needs creation :-) You'll also notice I did the Red Hat centric group named after the user, instead of using %G. Don't make the same mistake. Hope this helps. Steve Litt ----------------------------------------------------------
Robert -- why can't you just add a semicolon at the end after the fi, copy and paste your statement as a second statement, with a differeent filename. Also, given the complexity of the task, my preference would be to create a script holding the sh code, and simply have root preexec=/usr/local/samba/private/MakeTwoDirs Also try preexec = ./MakeTwoDirs Although like I said, I never got preexec to create directories. Steve At 06:38 PM 10/20/1999 +1000, Robert Jonsson wrote:>Hi Steve, > >And thanks for your answer. Unfortunately it does not solve my problem. >What I?m trying to do is to create two dirs using preexec in the same >service. It works well as long as I?m only creating one directory, what I >can?t figure out is how to create the second directory withing the same >service. Eg. How would I continue after the last "fi" in the script to >check for the second directory and create it if it does not exist? > >preexec = if [ ! -e /home/%U/dir1] then /bin/mkdir /home/%U/dir1; fi > >Robert > >Robert -- I've always had to use root preexec to create directories, even >though the user seemingly has permission to create it. >Here's my code to make [homes] refer to an smbhome below the home >directory, thus protecting the . files from Wacky Windows users: >[homes] >read only=yes >valid users=%U >write list=%U >root preexec=mkdir 0770 /home/%U/smbhome & chown %U:%U /home/%U/smbhome & >path=/home/%U/smbhome >browseable=no >You'll notice I'm not as diligent as you about checking whether the >directory needs creation :-) You'll also notice I did the Red Hat centric >group named after the user, instead of using %G. Don't make the same mistake. >Hope this helps. >Steve Litt > > >---------------------------------------------------------- > >
On Wed, 20 Oct 1999, Robert Jonsson wrote:> What I´m trying to do is to create two dirs using preexec in the same > service. It works well as long as I´m only creating one directory, what I > can´t figure out is how to create the second directory withing the same > service. Eg. How would I continue after the last "fi" in the script to > check for the second directory and create it if it does not exist? > > preexec = if [ ! -e /home/%U/dir1] then /bin/mkdir /home/%U/dir1; fiyou may have a syntax error in this '[' (test) command. make sure there is a space before the closing ']'. you can put multiple shell commands separated by semicolons in a preexec, so you should be able to use something like: preexec = if [ ! -e /home/%U/dir1 ] then /bin/mkdir /home/%U/dir1; fi; if [ ! -e /home/%U/dir2 ] then /bin/mkdir /home/%U/dir2; fi alternatively: preexec = [ ! -e /home/%U/dir1 ] && /bin/mkdir /home/%U/dir1; [ ! -e /home/%U/dir2 ] && /bin/mkdir /home/%U/dir2; -- Todd Pfaff \ Email: pfaff@mcmaster.ca Computing and Information Services \ Voice: (905) 525-9140 x22920 ABB 132 \ FAX: (905) 528-3773 McMaster University \ Hamilton, Ontario, Canada L8S 4M1 \
> Eg. How would I continue after the last "fi" in the script to > check for the second directory and create it if it does not exist?Why don't you just replace this whole line: preexec = if [ ! -e /home/%U/dir1] then /bin/mkdir /home/%U/dir1; fi ... with a shell script and pass the vars to it: preexec = /some/path/mkdirs %U In that script, do whatever you want. I did that a *long* time ago and actually used a Perl script instead of /bin/sh. It gives you unbelievable flexability.