Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am newbie just have a doubt,

I have a Outerl.sh to be executed on every zip file arrival in FTP and get the *.sh file inside the zip file and execute that (.sh) file which present inside the zip file.

Is this possible to execute the inner.sh using CronJobs Outer.sh.........?

Please help me to understatnd.Below is the just example structure.

***Outerl.sh
    --toexecute every file comes
FTP
  --file1.zip
  --file2.zip

file1
      --**.xml
      --**.doc
      --cronInner.sh
share|improve this question
    
Yes it is possible –  suspectus May 21 '13 at 8:34
    
Thankyou, Please make it is as answer if you can show some reference give link with answer or will delete this question. –  sunleo May 21 '13 at 9:49
    
Hope the answer suits your particular requirements. –  suspectus May 21 '13 at 10:59

1 Answer 1

up vote 1 down vote accepted

In your Outer.sh script the ftp files will be extracted. Assuming that the files will be placed in a directory where no other files exist, and that the .sh files that have been ftp'd are safe to execute.

Outer.sh

# read files in ftp directory
# extract zip files to tmp directory

cd tmp
for f in *.sh
do
   chmod +x $f  # ensure executable
   ./$f         # execute "inner" script
done

# remove files from tmp directory
share|improve this answer
    
+1 for safe. Bear in mind that anyone who acquires the ability to ftp files to that account can execute anything they like -- it doesn't have to be a shell script to end in .sh. –  Flup May 21 '13 at 11:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.