简体   繁体   English

在远程服务器上运行命令时,需要建议OS模块

[英]Need advise on OS module in running a command on remote server

I am having difficulty in running below command on remote server. 我在远程服务器上运行以下命令时遇到困难。 I have tried different modules like. 我尝试过不同的模块。 OS & Commands, But none of them able to execute the command as it is. 操作系统和命令,但它们都不能按原样执行命令。 I am getting either syntax error or un-desired output if I add extra quotes. 如果我添加额外的引号,我会得到语法错误或不希望的输出。 Can somebody please help with this. 有人可以帮忙解决这个问题。

mminfo -av -ot -q "client=test,savetime>=2 days ago" -r "group,client,sscreate(20),sscomp(20),ssflags,level,name,sumsize,pool" | grep "TEST"

I should have added this as an answer instead of a comment. 我应该将此作为答案而不是评论添加。

Just use subprocess.run subprocess.run(your_command, shell=True) 只需使用subprocess.run subprocess.run(your_command, shell=True)

your_command can be enclosed by single or triple quotes (not double because you are using them in your command). your_command可以用单引号或三引号括起来(不是双引号,因为你在命令中使用它们)。

your_command = '''mminfo -av -ot -q "client=test,savetime>=2 days ago" -r "group,client,sscreate(20),sscomp(20),ssflags,level,name,sumsize,pool" | grep "TEST"'''

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM