Man can someone hit me with an SSH script that could do the following: check in 100's of domain folders and see if the folder "upload" is in there.. If not, create the directory and set it to 777 and move to the next domain folder... So I would run the script at: /web/sites/vhosts/* (which contains tons of domains) and it would check just ONE LEVEL down and create the folder ONCE inside each domain. Many thanks for your help!
pico -w check.sh Code (markup): and then paste this: #!/bin/sh DirName="upload" cd /web/sites/vhosts/ for x in * do DOMAIN=$x cd /web/sites/vhosts/ USER=`ls -l | grep $DOMAIN | awk '{ print $4}'` cd /web/sites/vhosts/$DOMAIN/ if ! test -d "${DirName}" then mkdir $DirName chmod 777 $DirName chown $USER.$USER $DirName echo "Created folder and set chmod to 777 in: $DOMAIN" else echo "Folder already exists in: $DOMAIN" fi done Code (markup): then chmod this .sh script to 755 and that's it.. just run it btw: script will also change the ownership of the folder to the owner of that virtual domain... if you wish to have root as owners of all those 'upload' folders then just remove this lines: USER=`ls -l | grep $DOMAIN | awk '{ print $4}'` *and chown $USER.$USER $DirName Code (markup):
Oh and by the way... the part with checking for folder ownership may be the tricky part... because if virtual domain/user folder does not have a permission of that specific user (and is created with root ownership) then your upload folders will also have root ownership. You should check ownership of those folders in your /web/sites/vhosts/ folder. If you are using cPanel on your server, then it's structure will be fine, and script will do the work. Anyway... you can do ls -la in your /web/sites/vhosts/ and paste a few lines from there and I'll tell you, or you can just try and execute the script
Many thanks for the response! I didn't even realize you responded actually lol didn't have subscribe to thread turned on apparently. So this is what I went with: for f in *; do mkdir $f/foldername ; done Seemed to work great... Hey do you work with cURL? Thanks again! Mitch