【问题标题】:Missing trailing-' in remote-shell commandremote-shell 命令中缺少尾随-'
【发布时间】:2013-03-18 01:59:33
【问题描述】:

在我的 bash shell 脚本中,

rsync -a --delete -e "ssh -i /keypath" /source_dir/ username@remotehost:/dest_dir/

上面的任何组合[eval,双引号到单引号]都会给出以下错误,

remote-shell 命令中缺少尾随-'。 rsync 错误:../main.c(335) [sender=2.6.8] 处的语法或使用错误(代码 1)

但同样的命令直接在命令提示符下工作。 任何人都可以帮助我在这里缺少什么

谢谢

【问题讨论】:

  • 没有足够的信息来确定。尝试运行rsync -v -v -v,它将作为调试输出的第一行打印出正在远程服务器上运行的实际 shell 命令。

标签: bash shell rsync


【解决方案1】:

您的问题在于 bash 脚本中的嵌入引号。

Bash FAQ #50

查看以下解决方案(如果觉得有用,请点赞):

https://superuser.com/questions/354361/rsync-complaining-about-missing-trailing-in-a-bash-script

【讨论】:

    【解决方案2】:

    不确定你的问题是什么,但对我来说,大多数奇怪的 rsync 错误是由登录时.bashrc.bash_profile(或其他 shell rc 文件)输出的东西引起的。现在我通常将以下语句写为我的.bashrc.bash_profile 中的第一行

    # return if it's not an interactive shell
    [[ $- == *i* ]] || return 0
    

    【讨论】:

      【解决方案3】:

      一个对我有用的简单解决方案是使用 single 引号而不是 double 引号,即

      rsync -a --delete -e 'ssh -i /keypath' /source_dir/ username@remotehost:/dest_dir/
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-04-29
        • 2019-02-12
        • 1970-01-01
        • 2016-07-04
        • 2013-07-11
        • 2016-01-20
        • 2019-01-12
        • 2011-09-20
        相关资源
        最近更新 更多