Executing WINSCP script from a saved site
Please note that this is a Hosted~FTP~ resource, scripting support is available to our Enterprise level customers.
WinSCP offers a scripting interface that allows users to run a command from a file.
Please note: You need to run note pad as administrator when setting up your script.
To setup WinSCP automated scripting, follow the steps below:
Setup WinSCP for scripting:
- In the site manager, select what protocol you want to use and input your login credentials for your hosted~ftp~ account.
- Click save and then change the site name to something you will remember. For the sake of this article, we will call it “hostedftp” (optional).
- Check “Save password” and click on the ok button.
- Then login to make sure all the information entered in the site manager is correct.
Create your Bash script:
- Locate the Notepad program. Right-click the program and select “Run as administrator”
- Insert the following script: winscp.exe /console /script=script.txt
- You need to save the file in the C:\Program Files (x86)\WinSCP
- Save the file using the following settings: Save as type: All Files and File name: script.BAT
- Once again, locate the Notepad program. Right-click the program and select “Run as administrator”.
- Insert the following script but using your own credentials where necessary:
enter your commands after for example ls to list, mget to download multiple files, mput to upload multiple files and so on.
- Save the file as: script.txt in the “C:\Program Files (x86)\WinSCP” directory.
- Double click script.bat to run the script.
- To test it out, we will be running the script below:
# Connect to the server
#print Connection successful
echo Connection Successful!___________