Topic "SFTP Get error"

Author Message
guest123

Guest


I have this below script which gets the files from multiple sftp servers setup in csv file
each row of the csv file - source file/target file/source folder/target folder/sftp server details.

I loop through each row and get the file, this works, but fails when there is no file to get -"can't get attributes for file"

The problem to me is -
for each row I have one session or open command execution - This I didn't like. There are multiple rows in the csv file with same server details. I want to look through each row and see if its a new sftp server, if it is, create a new session and get the file.

To accomplish this, I tried using a flags and check if the previous row host and current is same, if same I wanted to use the same session..
Here is the catch -
after opening the session, it doesn't allow any windows batch commands in between winscp commands

Need your help to find a solution to this generic solution.

@echo
(
FOR /f "tokens=1-12* delims=," %%A IN (D:\GENSRVNT\SFTP_TOOL_WK\sftpconfig_Get.csv) DO (

"C:\Program Files (x86)\WinSCP\WinSCP.com" /log="D:\GENSRVNT\SFTP_TOOL_WK\TestSFTPLog.txt" /command >> "D:\GENSRVNT\SFTP_TOOL_WK\TestSFTPLog1.txt" ^
"open sftp://"%%~F"@"%%~H"/ -hostkey=""%%~I"" -privatekey=""%%~J"" -passphrase=""%%~K"" " ^
"get -append -delete -resumesupport=off %%~A/%%~B %%~D\%%~C" ^
"exit"

if %ERRORLEVEL% neq 0 (
)
)
)
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27083
Location: Prague, Czechia
That's too complicated for a batch file.

Use PowerShell (or other good scripting language) and WinSCP .NET assembly.

https://winscp.net/eng/docs/library_powershell
Advertisements

You can post new topics in this forum

Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License