Re: FIlenames with space issue - need help
@marunachalam: Your code does not even attempt to "pull" anything. There's no file transfer command (
get
nor put
).
get
nor put
).
"FTPV|SeekingAcoustic|/download/|SeekingArrangement -*|E:\ETL\SeekingArrangements\WORKPROFILE\SourceFileList|OldestFirst|"
FOR /F "tokens=* USEBACKQ" %%F IN (`powershell -Command "[guid]::NewGuid().ToString()"`) DO (SET r=%%F)
echo %1 > %tmpdir%\%r%.ftplsseeking
REM var1=FTP Connection
REM var2=Remote FTP directory
REM var3=Filemask to list
REM var4=Local dir/name of list file
REM var5 = Sort Order "NewestFirst" or "OldestFirst"
REM ------------------------------------------------------
set var1=""
set var2=""
set var3=""
set var4=""
set var5=""
for /f "tokens=2 delims=|" %%A IN (%1) DO set var1=%%A
for /f "tokens=3 delims=|" %%B IN (%1) DO set var2=%%B
for /f "tokens=4 delims=|" %%C IN (%1) DO set var3=%%C
for /f "tokens=5 delims=|" %%D IN (%1) DO set var4=%%D
for /f "tokens=6 delims=|" %%E IN (%1) DO set var5=%%E
if %var1% == "" GOTO :ERROR4
if %var2% == "" GOTO :ERROR4
if %var3% == "" GOTO :ERROR4
if %var4% == "" GOTO :ERROR4
REM -----------------------------------------------
winscp.com /command "option batch abort" "option confirm off" "option echo on" "open %var1%" "cd /" "cd %var2%" "ls ""%var3%""" "exit" >> %tmpdir%\%r%.ftplsseeking
if %errorlevel% equ 0 GOTO :GOTIT
I am using the below command and the local path is having space, so made it under two double quotes
But still I'm getting errorToo many parameters for command 'lcd'.
/loglevel=1
.
Too many parameters for command 'lcd'.
lcd
.
"C:\Program Files\WinSCP\WinSCP.com"
/log="d:\WinSCP.log" /ini=nul
/command "option confirm off"
"option batch continue"
"open sftp://testuser:password@20.20.20.20/"
"cd /44/remotepath/2021/MAR/remotefolder"
"lcd ""Z:\test path\2021\Mar"""
"get REMOTEFILE.TXT" "exit"
confirm off
batch continue
Searching for host...
Connecting to host...
Authenticating...
The server's host key was not found in the cache. You have no guarantee that the
server is the computer you think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 ************************
If you trust this host, press Yes. To connect without adding host key to the cac
he, press No. To abandon the connection press Cancel.
Continue connecting and add host key to the cache?
(Y)es, (N)o, C(a)ncel, (C)opy Key: Yes
Using username "testuser".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] testuser@20.20.20.20
/44/remotepath/2021/MAR/remotefolder
Too many parameters for command 'lcd'.
REMOTEFILE.TXT | 0 KiB | 0.0 KiB/s | binary | 100%
I still dont quite get why this works though, because the double-double quotes (according to the documetnation), are designed to escape a quotation character(use literally) - at least according to the explanation.
Command parameters that include space(s) have to be enclosed in double-quotes. To use double-quote literally, double it:
Command parameters that include space(s) have to be enclosed in DOUBLE-double-quotes. To use double-quote literally, double it:
put "file with spaces and ""quotes"".html"
put ""file with spaces and ""quotes"".html""
So, seems there is nothing documented for spaces passed inside a PARAMETER to the application(not in a script!).
winscp.exe /ini=C:\WinSCP.ini" SessionName1 /console /command "cd ""/home/username1/logs/uut/MN00093\IVT Gen2""" "get event* c:\tmp"
Regarding the bit about/defaults
– what I mean is, if I for example use /synchronize parameter - if I dont specify the /default parameter, its gonna ask the user, whether I want to port to local, remote, which files to overwrite etc.
Is there a way to specify all these options manually in command line parameters? other than/defaults?
Command parameters that include space(s) have to be enclosed in double-quotes....put "file with spaces and ""quotes"".html"
/command
parameter to RUN the application in /console
mode.
winscp.exe /ini=C:\WinSCP.ini" SessionName1 /console /command "cd "/home/username1/logs/uut/MN00093\IVT Gen2"" "get event* c:\tmp"
Error changing directory to '/home/username1/logs/uut/MN00093\IVT'.
Cannot get real path for '/home/username1/logs/uut/MN00093\IVT'.
/defaults
– what I mean is, if I for example use /synchronize
parameter - if I don't specify the /default
parameter, its gonna ask the user, whether I want to port to local, remote, which files to overwrite etc.
/defaults
?
Also - one more question please: how do I specify actions other than the/defaults
parameter? so I can customize the actions via the command line parameters too :)
winscp.exe /ini=C:\WinSCP.ini" SessionName1 /console /command "cd /home/username1/logs/uut/MN00093\IVT Gen2" "get event* c:\tmp"
Too many parameters for the command 'cd'.
\
to escape the space, I tried the web standard of %20
- nothing works.
/defaults
parameter? so I can customize the actions via the command line parameters too :)