问题
Upload file via FTP from Excel VBA was very helpfull, I'm using the code to synchronize a local folder to my FTP server.
Call Shell( _
CurrentProject.Path & "\WinSCP.com /log=" & CurrentProject.Path & "\ftp.log /command " & _
"""open ftp://user:pass@ftp.server.com/"" " & _
"""synchronize local " & localfolder & " /www/remotefolder/wines -filemask=""*.png"" " & _
"""exit""")
I'm trying to issue an exit
command at the end, but the code gives me a
Too many parameters for command 'synchronize'.
The line in the log tells me
synchronize local C:\localfolder\wines /www/remotefolder/wines -filemask=*.png exit
The exit
is in the same line as the synchronize
one, when I use the put script this doesn't happen. What can I do to prevent this?
回答1:
You are missing closing quote after the synchronize
command. And the quotes around -filemask
value have to be doubled. Or actually, you do not need them, as the value does not contain spaces.
This will do:
"""synchronize local " & localfolder & " /www/remotefolder/wines -filemask=*.png""" & _
See https://winscp.net/eng/docs/commandline#syntax
The symbol you have at the beginning of —hostkey
and —rawsettings
is not a simple hyphen-minus (-
), but em-dash (—
).
Please use hyphen-minus (-
) — what is the dash that you find on the standard English [and other] keyboards.
So actually you have the very same problem as in WinSCP forum post you referred to.
Or even easier, have WinSCP GUI generate a script template for you.
Other questions with the same error message, but different problem:
- WinSCP command line - Too many parameters for command 'open' when using -rawtransfersettings switch
- WinSCP "Too many parameters for command 'open'." error
- FTP "Too many parameters for command 'synchronize'" with WinSCP
来源:https://stackoverflow.com/questions/47865865/getting-too-many-parameters-for-command-when-calling-winscp-command-line-from