Download files every one second using ftp script

Our main Server "Srv1" is used to generate text files based on specified criteria and it is also connected to two clients (pc1 and pc2) which are responsible for getting the files from Srv1 as it follows:

  1. pc1 ( which represents my UNIX machine ) uses shell script to copy the files from Srv1
  2. pc2 ( which is represent my colleague window machine ) uses another technique to cut the file from Srv1

my shell script includes below ftp session to copy the files from Srv1 to pc1 , In fact I run it for 2 days as cronjob for every minute and it was working fine but while did compare the collected files on pc1 with collected files on pc2 I found that pc2 has files more than what pc1 has ( cause pc2 cut some files faster than pc1 which gets the files every one minute ) !!!

:confused:I want to run my script every 1 second or less than if possible to copy the files to pc1 before going to be taken or cut by pc2 , any clue ???

ftp -in x,x,x,x  << ENDFTP
user username password
cd $ddir
lcd $sdir
bin
prompt
mget *.text
bye
ENDFTP

Before allowing 'pc2' to get/remove the file(s) it needs to make sure that 'pc1' has gotten the file(s), there are multiple ways to accomplish this, one way is to have 'pc1' create a 0 byte file in the directory on the host where it got the file(s) for each file(s) it successfully got, then the script on 'pc2' would only get/remove the file(s) that have been successfully processed by 'pc1' and when 'pc2' got a file it would also remove the temp file that told it it could get remove the file.

Does Svr1 support inotify(is it Linux?)

You should NOT poll for files as you are doing things. Svr1 knows when a local file is closed, it is hard to do that reliably using ftp from a remote connection.

Set up a file watch on Svr1, have it move files to a special subdirectory. Any file in that subdirectory is complete and ready to ftp. Run ftp once per minute - have it list files in that special subdirectory. Use the output of that as an input list of files to grab.

Running ftp every second is a disaster waiting to happen. Consider something else.

I have no right to play with Srv1 ..

---------- Post updated at 04:42 PM ---------- Previous update was at 04:41 PM ----------

please do the code for me ..