1834237 Members
2666 Online
110066 Solutions
New Discussion

ftp status

 
LeAnn
Occasional Contributor

ftp status

Hello all AlMighty_Masters,

I have a script which ftp some big file from the system. My script would then use this ouput file it just ftped to execute another command, say, "awk".
My problem:
as awk picks up, the ftp is done executed but the file is NOT done being transfered. so my awk reads in incomplete information because the, say, "ftp.out" file is not finished being transfered.
Question:
Is there anyway that I can halt awk from being executed until the ftp.out file is completely transfered so that it reads in complete information. may be keep track of the size of ftp.out, or reply codes from ftp, or something.

Please, advise.
Thank you all very much.

PS: the ftp uses a .netrc file which i don't completely understand:

~~~~~~~~~~~ .netrc
machine MACHINE login USER password SOME_PSWD
macdef init
site file=jes <<--- not sure what this is
supposed to do
put &HOME/transfer.jcl <<<--- also this???
quit
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

6 REPLIES 6
Ken Hubnik_2
Honored Contributor

Re: ftp status

You can send another file .done after the original ftp and check for the existance of the .done file. Also, I beleive that while a file is being ftp'ed the file has no permissions. You can also put a sleep in the script to allow for large files or slow network.
John Palmer
Honored Contributor

Re: ftp status

I always run 'fuser' on the received file to check that it's not in use before attempting to process it. A shell script can do something like...

if [[ -n $(fuser FILENAME 2>/dev/null) ]];
then
fi

Regards,
John
LeAnn
Occasional Contributor

Re: ftp status

Hello Ken,
Thanks for replying quick.
I still have some problem, thou.
I tried to use the 0-byte .done way, but does that mean that I have to interfere with the .netrc file? This is what i did, would you check my steps:
In the .netrc, I "put .done" in the remote directory, and then "get .done" after BigFILE is transferred, and in my script I check for .done.
But it kept saying it can't recognize the "site file=transfer.jcl" line. It doesn't do this before.

Sleep would work, but this script needs to work for different files. So, when the size of my BigFILE changes, then I have to wait for a long time in case the BigFILE is shorter, and it might not be Enough time when BigFILE is bigger.
Rory R Hammond
Trusted Contributor

Re: ftp status

When I ftp files. That are going to be picked up and run on a receiving system. I put the file to a temp name. after the put is completed. I rename it to the final name. A rename is immediate;


put file.tmp
rename file.tmp file.out

This would also fix your problem of awk starting to soon.
There are a 100 ways to do things and 97 of them are right
rick jones
Honored Contributor

Re: ftp status

i rather like the fuser idea, but one advantage the rename path has is that (presumeably) it would only be done when the file is transfered completely. (assumes the sender is checking the result of the transfer).

fuser would show now user of the file even if the ftp session aborted for some reason.
there is no rest for the wicked yet the virtuous have no pillows
LeAnn
Occasional Contributor

Re: ftp status

Hello Gentlemen,
I ran into another problem. So I have to wait until they decided what to do. then I can try out your ideas. I'm sure they would work.
I don't want to just disappear, so ...
Thank you all very much. I'd let you know when i got some results.

Again, thank you very much.
Best regards,
Leann