Posting multiple commands in WinSCP.com

Advertisement

llong
Joined:
Posts:
1

Posting multiple commands in WinSCP.com

I have to write a script that is for a 32-bit machine to perform SFTP. I need to be able to process multiple commands as different point in the script. In short...
1) Connect to SFTP server
2) Pull a file of available files
3) Parse the list and for each file...
a. Upload the file
b. Perform a process for each file

I am pulling the list using the ls command in strArg..
winscp.StandardInput.WriteLine(strArg);
winscp.StandardInput.Close();
...but when I try to write any subsequent command, I get an error citing "Cannot write to a closed TextWriter". Without the Close() command, the process hangs. How do I invoke the ls without closing the TextWriter?

Thank you

Reply with quote

Advertisement

Nguyen Duc Tien
Guest

Copy multi files from a list to Linux Server

In my case, I'd like to copy files in a list to an SSH server. So I guess you want something like that. This is my batch file and it run well.
set WINSCP=D:\Softwares\winscp.com
set REMOTE_STRING=tiennd:password@techlinkvn.com
set REMOTE_FOLDER=/home/tiennd/MycelScrapy/
 
set SRC_LIST=README.md scrapy.cfg
 
@echo off & setlocal
setlocal EnableDelayedExpansion
set winscp_commands=
(for %%f in (%SRC_LIST%) do ( 
   set winscp_commands=!winscp_commands! "put %%f %REMOTE_FOLDER%"
))
 
%WINSCP%  %REMOTE_STRING%  /command   %WINSCP_COMMANDS%  exit

sample.png

Reply with quote

Advertisement

You can post new topics in this forum