Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

jan_van_man

Re: Manual transfer fine but script not working

Ah I can't believe it! So simple. Thanks Martin
jan_van_man

Manual transfer fine but script not working

Hi,

I have quite a few scripts that follow this batch script syntax and format and they all work fine. There is one that isn't working (different SFTP location) when using a script but when using the GUI, I'm able to download files from the SFTP.

The script is
@echo off
 
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\FTP\WinSCP.log" /ini=nul /loglevel=2* ^
  /command ^
    "open sftp://UserName:Password@sftp.clientname.co.za/ -hostkey=""ssh-rsa 1024 7UI9GKZvOKnqKO3K21hvtyx4a8s2gxH7D8RrNeWJN38="" -rawsettings FSProtocol=2 ProxyPort=0" ^   
    "cd /" ^
    "lcd C:\FTP\Files\ClientName" ^
    "synchronize local -filemask=*.*>1DS" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%

When I try running this I get this and then it sticks:

Searching for host...
Connecting to host...
Authenticating...
Using username "UserName".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] UserName@sftp.ClientName.co.za
winscp>

I've attached the log results