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.
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.