SFTP Downloads

I was wandering if it is possible to automatically connect to a sftp site and download files ?

what i would like to do is download the same file over and over for the reasons of
1. Test FTP speed with that i would have a saved Log text file with time it took to download
2. Test connective to the FTP Server that if connection failed i should receive an email
DavidfoleyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

savoneCommented:
What kind of machine are you using to download?

If it is a linux machine, you can use the sftp command line tool and set a cronjob or write a script to loop.

If you are using windows, I would suggest writing a small script for winscp.
DavidfoleyAuthor Commented:
Hi Savone.

Im using Windows. can winscp display time stamps ? and email notifications if connection fails ?
savoneCommented:
Here is a simple script that will fetch a file 10 times (Change 10 in the while statement to fetch as many times as you like):

#!/bin/bash
count=0
while [ "$count" -le "10" ]; do
        sftp -P 2222 user@remotehost:/absolute/path/to/file.jpg
        let "count=count+1"
done

Open in new window


Of course this will fetch the file again and again quickly, if you want to have a 10 second pause in between downloads you can add a sleep like so:

#!/bin/bash
count=0
while [ "$count" -le "10" ]; do
        sftp -P 2222 user@remotehost:/absolute/path/to/file.jpg
        let "count=count+1"
        sleep 10
done

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
savoneCommented:
As far as WinSCP and email notifications, I don't think that functionality is there.  Here is the documentation for WinSCP scripting and automation:

http://winscp.net/eng/docs/scripting
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.