从VBA调用WinSCP命令行时获取“命令参数太多” [英] Getting "Too many parameters for command", when calling WinSCP command-line from VBA

查看:262
本文介绍了从VBA调用WinSCP命令行时获取“命令参数太多”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Excel VBA通​​过FTP上传文件非常有用,我正在使用代码将本地文件夹同步到我的FTP服务器。

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""")

我试图在最后发出 exit 命令,但是代码给我一个

I'm trying to issue an exit command at the end, but the code gives me a


命令'synchronize'的参数太多。

Too many parameters for command 'synchronize'.

日志中的行告诉我

synchronize local C:\localfolder\wines /www/remotefolder/wines -filemask=*.png exit

退出 synchronize 处于同一行,当我使用put脚本时不会发生这种情况。我该怎么做才能防止这种情况?

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?

推荐答案

同步命令。并且 -filemask 值附近的引号必须加倍。或者实际上,您不需要它们,因为该值不包含空格。

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.

这可以做到:

   """synchronize local " & localfolder & " /www/remotefolder/wines -filemask=*.png""" & _

请参见 https://winscp.net/eng/docs/commandline#syntax

(主机密钥 -rawsettings )开头的符号不是简单的连字符减-),但短划线-)。

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.



实际上,您遇到的问题与您提到的WinSCP论坛帖子

或更简单的方法是 WinSCP GUI会为您生成脚本模板

另请参阅常见问题解答为什么在批处理文件中指定的某些WinSCP脚本命令未执行/失败?

Also see FAQ Why are some WinSCP scripting commands specified in a batch file not executed/failing?

其他具有相同错误消息,但问题不同的问题:

  • 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

这篇关于从VBA调用WinSCP命令行时获取“命令参数太多”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆