linuxrecursionftppsftp

PSFTP (Linux) how to run a while loop


I'm writing a shell script to download a log file from remote linux server onto my local windows pc (after performing several other operations) i.e. once all other operations (eg read, write, put, get etc) have completed on the remote server and the log file 'has' been successfully written, I want to download it. I'm trying to use a while loop for this.

In this I'm checking if one of the files that I FTP'd exists on the server or not. If it doesn't exist (since the server deletes the file after sometime and writes to log file), download log file. If the file still exists, keep waiting for it to be deleted. Following is a snippet:

call while [ ! -f /tmp/foo.txt ]; sleep 2; done
get FileWriter1.log

The problem is that the while command isn't being recognized by pftp. I've even tried putting a 'call' before it but it still doesn't work. How can I make it run?

Thanks for all your help in advance.


Solution

  • There's no call command in psftp.

    Your script actually looks like WinSCP script.

    WinSCP has both call and get commands.