Search code examples
batch-filesftpwinscp

Running WinSCP script for Data transfer automation from remote to local


I wrote a code to transfer data from remote drive to local drive. However, I am getting an error

Scripting does not use standalone parameters. The parameters you have specified on command-line will not be used. Your command-line syntax is probably wrong.
Opening session using command-line parameter in scripting is deprecated. Use 'open' command instead.
Host:
Host:

Appreciate your support.

Code

option batch abort
option confirm off
open sftp://username:password@server -hostkey="host key"
synchronize local "\\Local Path" 
/remote path
exit

Then I created a bat file,

winscp.com/SMS_BASES_SAMBA_TO DRIVE.txt

Solution

  • You didn't really explain us, what did you intend to achieve with this:

    winscp.com/SMS_BASES_SAMBA_TO DRIVE.txt
    

    So I can only guess that the SMS_BASES_SAMBA_TO DRIVE.txt is a filename of your WinSCP script.

    If that's correct, then the right syntax is:

    winscp.com /script="SMS_BASES_SAMBA_TO DRIVE.txt"
    

    That is:

    • Use /script switch to specify the script file
    • Wrap the filename to double quotes, as it contains a space.

    Additionally, it's recommended to add /ini=nul and /log=....


    Note that you have the synchronize command broken into two lines. It should be one line only and the remote path should be quoted too (if it has spaces):

    synchronize local "\\Local Path" "/remote path"