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

martin

Re: Batch file for file transfer from network shared path to unix server

1) I'm pretty sure that C:\writable\path\to\log\WinSCP.log is not a valid existing path on your system. Use a real path, instead of this placeholder.
2) Your batch file syntax is wrong. You cannot have an unescaped empty line between "open" and "put" lines.
3) It seems that you have a new line between "ssh-rsa 2048" and "k6KSozSpdMksDTVkhLKUR7GDKgTHspD5cgeYTRENsU8".
Zapp

Batch file for file transfer from network shared path to unix server

Hi,

I have to automate file transfer from NAS path location to unix server. Have been using below code but its throwing error as mentioned below (Also not able to find the winscp.log file in my system, can it work without that, if not what can be the alternative approach):

code:

@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\writable\path\to\log\WinSCP.log" /ini=nul ^
/command ^
"open sftp://zapp:xxx@hostname/ -hostkey=""ssh-rsa 2048 k6KSozSpdMksDTVkhLKUR7GDKgTHspD5cgeYTRENsU8=""" ^

"put filename.txt /home/zapp/Testdir/filename_Test.txt" ^
"exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)

exit /b %WINSCP_RESULT%

Result:
Please find attachment.