在批处理脚本中管理特殊字符以编写winscp打开连接字符串

问题描述 投票:0回答:1

我正在尝试编写批处理代码以将脚本生成到文件中,以打开与winscp的连接;最终命令应类似于:“ open sftp:// user:[email protected]/”(不带引号)。密码包含字符“ +”,我必须将其更改为&2B才能使winscp成为下划线。

set pw=mypassword+
::echo %pw% return--> mypassword+
set st=%%2B
::echo %st% return--> &2B
call set pw=%%pw:+=%st%%%
::echo %pw% return--> mypassword2B

我找不到最后一次调用以返回%pw%= mypassword%2B(%在2B之前)传递给winscp脚本的方法。你能帮我吗?还有另一种策略(但总是批量处理dos)使open winscp命令接受正确的密码吗?提前致谢。 [email protected]

windows batch-file cmd winscp ssh2-sftp
1个回答
0
投票
setlocal enabledelayedexpansion set pw=!pw:+=%%2B!

注意,您必须删除call

基于Batch - replacing with percent symbol

此外,还有另一种向WinSCP提供密码的方法:


open ftp://[email protected]/ -rawsettings PasswordPlain="mypassword+"
© www.soinside.com 2019 - 2024. All rights reserved.