运行“docker stop $(docker ps -a -q)”时出现“非法变量名”错误

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

我试图使用Python的paramiko包在ssh上发出命令docker stop $(docker ps -a -q)

stdin,stdout,stderr = ssh_client.exec_command('docker stop $(docker ps -a -q)');
print stderr.readlines()

我收到错误Illegal variable name。我尝试输入双引号(“”),逃避$,(,)......但是用尽了想法

python-2.7 paramiko csh
1个回答
1
投票

听起来你正在使用作为ssh服务器上的登录shell。 Csh不支持$(...)所以试试

ssh_client.exec_command('docker stop `docker ps -a -q` ');

Csh示例:

# echo $(echo foo)
Illegal variable name.
#
© www.soinside.com 2019 - 2024. All rights reserved.