View Single Post
  #1  
Old 27th September 2009, 02:26
Leszek Leszek is offline
Senior Member
 
Join Date: Nov 2006
Location: Poland,Włocławek
Posts: 369
Thanks: 22
Thanked 42 Times in 35 Posts
Send a message via Skype™ to Leszek
Default Executing all shell scripts in specified directory

Hi,

I need to write a shell script that would:
-check if a specified directory exists and contains any files
-chmod and chown all files inside the directory
-execute all shell scripts in that directory (*.sh)

That script would be run by Cron using root account.
So far I came up with something like this:
Code:
#!/bin/bash
KATALOG=/var/scripts
if [ -d $katalog ]; then
chmod -R 700 /var/scripts
for SCRIPT in $katalog
do
if [ -f $SCRIPT -a -x $SCRIPT ]
then
$SCRIPT
fi
done
else
echo "ERROR! The directory doesn't exist."
exit 1
fi
Please help me in making it do what it's supposed to do.
Thanks in advance!
Reply With Quote
Sponsored Links