我正在尝试编写python脚本,它将传递以下命令以在特定服务器中执行。
ssh server 'mongo /path/to/file --eval "print('123456\t78');"'
上面的命令被传递到脚本中的以下函数:
^{pr2}$结果,我得到了以下输出:
the command: ssh server 'mongo /path/to/file.js --eval "print('123456\t78');"'
MongoDB shell version: 2.6.11
connecting to: test
2016-01-26T09:42:51.084+0000 SyntaxError: Unexpected token ILLEGAL
但是,当我尝试直接在服务器上执行'mongo /path/to/file.js --eval "print('123456\t78');"'
时,它会很好地工作,因为我得到的结果是:
MongoDB shell version: 2.6.11
connecting to: test
123456 78
test
1
0
我怀疑,这一定与ssh server
后的(单)引号有关。所以我的问题是,用特殊字符(如引号或斜杠)传递命令的最佳方法是如何与ssh命令一起运行的?
目前没有回答
相关问题 更多 >
编程相关推荐