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

查看:19
本文介绍了从 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

命令同步"的参数过多.

Too many parameters for command 'synchronize'.

日志中的那行告诉我

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

exitsynchronize 位于同一行,当我使用 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?

推荐答案

synchronize 命令后缺少右引号.-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

—hostkey—rawsettings开头的符号不是简单的连字符-减号(-),但em-dash ().

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 脚本命令未执行/失败?

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

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

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