gpt4 book ai didi

bash - 从 Windows cmd 在 bash 中调用 rsync

转载 作者:行者123 更新时间:2023-12-04 19:00:17 24 4
gpt4 key购买 nike

我正在尝试运行 rsync从批处理文件。命令是

SET CMD="rsync -P -rptz --delete -e 'ssh -i /root/.ssh/CERTIFICATE.pem' SOURCE_ADDRESS  /mnt/c/Users/MYNAME/IdeaProjects/PROJECT/SUBFOLDER/SUBFOLDER/SUBFOLDER/SUBFOLDER/LASTFOLDER"

bash %CMD%

如果我在输入 bash 后运行命令,这会正常工作,但是当我使用 bash 从 cmd 运行命令时前兆它说没有这样的文件或目录。

此外,在玩耍并尝试调试 bash 时会挂起……即,如果我打开 bash,我没有得到任何提示,只是一个闪烁的光标。

任何帮助表示赞赏。

最佳答案

要使用 bash 运行命令,您需要使用 -c option

bash -c "%CMD%"

如果没有它,第一个非选项参数将被视为 *.sh shell 脚本, rsync不是并且会导致错误

If arguments remain after option processing, and neither the -c nor the -s option has been supplied, the first argument is assumed to be the name of a file containing shell commands.



请注意,Windows 中的 cmd 不是 DOS,即使它们有一些类似的命令。其余的差别很大

关于bash - 从 Windows cmd 在 bash 中调用 rsync,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56259041/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com