0

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.

Chipmunk_da
  • 467
  • 2
  • 9
  • 27

1 Answers1

0

There's no call command in psftp.

Your script actually looks like WinSCP script.

WinSCP has both call and get commands.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Hi Martin, I was using winscp earlier but later decided not to. Since call worked in winscp, I though it might work for psftp too but it didn't. Why certain commands like 'while' can't be run normally? And what is the alternate syntax to run them? – Chipmunk_da Oct 28 '16 at 16:17
  • What makes you expect that you can run shell commands in SFTP client, in the first place? – Martin Prikryl Oct 28 '16 at 18:17
  • Hi Martin, I think now I've started to understand this. Since I'm quite new to shell scripting and Linux, I had assumed that an SFTP client can send the shell commands to the server to execute just like it does for other commands like get, put etc – Chipmunk_da Oct 29 '16 at 20:12
  • The `get` and `put` are not sent to the server. These are commands of the local specific SFTP client. Other clients can have different commands or different options. Note for example different semantics of the `get` in psftp, WinSCP and OpenSSH. – Martin Prikryl Oct 29 '16 at 21:00
  • That makes complete sense now. Thanks for explaning Martin :) – Chipmunk_da Oct 30 '16 at 01:46