Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am newbie just have a doubt,

I have a 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 using CronJobs

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

    --toexecute every file comes

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
up vote 1 down vote accepted

In your 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.

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

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

# 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .