Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Start running scripts

Status
Not open for further replies.

jayjaybigs

IS-IT--Management
Jan 12, 2005
191
CA
Hello,

I was wondering if anyone has an input for the following questions.

1) I am interested in starting my shell script only after the existence of a particular file.
For example, I have directory - personals, in this directory there is personals.sh .
I would like to start personal.sh only when there is employee.txt which is an input for the personal.sh
employee.txt could come any time and personal.sh should be triggered when employee.txt arrives.
I would have prefered to write a crontab job for this, but user prefer it to execute only when the file exist as supposed to periodic running.

2)Also, could you point me to any code line that would send file, not FTP, from remote server to local drvie c: on the sqme network

Thanx
 
1) you would have to have something running constantly (or intermittently via cron) to poll for the file.

2) define "send"
 
jayjaybigs said:
I would have prefered to write a crontab job for this, but user prefer it to execute only when the file exist as supposed to periodic running.

Sometimes user take what user can get.
 
I'm with ChipperMDW on this, but if you must you could start a script in the background that calls itself after sleeping for a defined interval, like:

<run script>
sleep <period>
<run script>

NB - it is difficult to be sure that this job won't be killed or just drop out - hence the opinion that cron is probably more reliable for such a task.

Of course, you need to ensure that even if the file is there, it is complete (ie not in the middle of a transfer) - in that case, you might want to check for the existence of a check file to tell you that the transfer is complete. There are several examples of such a script in this and the Unix Scripting forum. Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top