$ ssh root@123.123.123.123
123.123.123.123# pkill -f "stalled process name"; commands_to_restart; some_more_commands;
many many lines of output demonstrating success
123.123.123.123# exit;
所有工作都很完美
$ ssh root@123.123.123.123 "pkill -f "\""stalled process name"\"";"\
> "commands_to_restart; some_more_commands;";
没有输出,什么也不做。
$ ssh root@123.123.123.123 "echo "\""pkill -f "\"\\\"\""stalled process name"\"\\\"\""; "\
> "commands_to_restart; some_more_commands;"\"";";
pkill -f "stalled process name"; commands_to_restart; some_more_commands;
所以..。引用转义的两个阶段如预期的那样工作。
如何让单层引号转义与ssh/bash一起使用?由于quoting在两层中都能很好地工作,我有一种感觉,它与quoting的关系不大,而更多地与ssh
对终端的处理有关。然而,据我所知,这些命令只是对标准输出进行简单而常规的IO,而不是输入。
发布于 2018-05-09 08:29:42
尝试:
ssh root@123.123.123.123 'pkill -f "stalled process name"; commands_to_restart; some_more_commands'
使用单引号中的命令,不需要转义内部的双引号。
如果您只喜欢使用双引号,那么内部双引号的单转义应该是令人满意的:
ssh root@123.123.123.123 "pkill -f \"stalled process name\"; commands_to_restart; some_more_commands"
https://stackoverflow.com/questions/50243794
复制相似问题