scheduling a perl script

M

mike

hi

i wrote a script that is supposed to check a directory and see if
there is a file named "test.txt" there and if there is , use ftp to
transfer the file to another server and then remove the file from the
directory.
I had scheduled a job in windows to poll for this directory looking
for "test.txt" every month on day 8, 9 and 10 and 11, because test.txt
will arrive anytime during 8,9 and 10. On the 11th, my script will
poll the directory and if there is still no test.txt, will alert the
administrator.

How can i implement in perl such that on the 11th, my script will not
mistake that test.txt is not there while in fact, it has already been
transfered to another server and removed after transfered?
I thought of not removing test.txt after transfered but if the file
arrived on the 8th, then on the 9th i would do another identical
transfer.

I also thought of using a "status" file. Something like

open ( STATUS , "> status.out");
print STATUS "0";

then if test.txt arrrives, do the transfer, remove the file and update
STATUS.
Is this the correct way to do ??
thanks
 
B

Ben Morrow

How can i implement in perl such that on the 11th, my script will not
mistake that test.txt is not there while in fact, it has already been
transfered to another server and removed after transfered?
I thought of not removing test.txt after transfered but if the file
arrived on the 8th, then on the 9th i would do another identical
transfer.

I also thought of using a "status" file. Something like

open ( STATUS , "> status.out");
print STATUS "0";

then if test.txt arrrives, do the transfer, remove the file and update
STATUS.
Is this the correct way to do ??

I would simply use the presence or absence of your status file. So start
with it not there; when you ftp the file, delete it and create your
status file; on day 11, check for the status file and remove it.

Ben
 
A

Anno Siegel

mike said:
hi

i wrote a script that is supposed to check a directory and see if
there is a file named "test.txt" there and if there is , use ftp to
transfer the file to another server and then remove the file from the
directory.
I had scheduled a job in windows to poll for this directory looking
for "test.txt" every month on day 8, 9 and 10 and 11, because test.txt
will arrive anytime during 8,9 and 10. On the 11th, my script will
poll the directory and if there is still no test.txt, will alert the
administrator.

How can i implement in perl such that on the 11th, my script will not
mistake that test.txt is not there while in fact, it has already been
transfered to another server and removed after transfered?
I thought of not removing test.txt after transfered but if the file
arrived on the 8th, then on the 9th i would do another identical
transfer.

One solution might be to let it do just that. What's a spurious file
transfer or three among friends? On the 11th, delete it to stop the
transfers. If there's nothing to delete, blow the horn.
I also thought of using a "status" file. Something like

open ( STATUS , "> status.out");
print STATUS "0";

then if test.txt arrrives, do the transfer, remove the file and update
STATUS.
Is this the correct way to do ??

Your question has nothing to do with Perl. The problem would be the same
if you were to implement it in any other language.

A status file is one solution, but you may not need one, even if you
want to avoid extra transfers.

Don't remove the file, move it, to a subdirectory "done" for instance.
Then it won't invite another transfer, but it's still around to show
it's been dealt with. Again, clear the "done" directory every 11th.

Anno
 
G

gnari

[snip question]

a) use a better subject line. this question is not really about
scheduling a perl script

b) this is not really a perl question. figure out how you want to do
it, and if you have problems with the perl implementation, ask
about that.
but to answer it, yes a status file would be one way of doing it,
either by testing a value in it, or even just by testing for its
presence.
if you use a value in the flag, you must either reset the value after
the last check so that it will not interfere with next month's file

c) assuming it IS a perl question:
open ( STATUS , "> status.out");

check if the open succeeded
if you do not use a full path to the file, make sure
the current directory is correct

gnari
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top