Do you want to get all *.csv files from an sftp server, or particular ones?
The easiest way is to use public key authentication, with ssh-agent, and use ssh-add to save the passphrase for your private key. Then you can simply use a batch file to retrieve the .csv files.
Example:
Code:
eval $(ssh-agent)
ssh-add
<PASSPHRASE_ENTERED>
ssh -b ftpscript user@host
I tried this out just now on my laptop. The ssh server is my desktop. I did it for ogg instead of csv files because I had ogg files on my desktop.
The script was
For unattended cron jobs, you may need to use a private key without a passphrase. The passphrase protects the private key on the client, not on the sftp server. The server has a copy of your public key.
Here is another example. Given how simple the request is, I supplied the batch command on the fly:
Code:
sftp -b <(echo 'mget *.ogg') elite
Use username@host instead of elite. If the user is the same, you only need the hostname.
If you can use the scp program, it would be even simpler.
Code:
scp elite:'*.ogg' .