[英]How to execute the command from another shell in python?
我想运行一些命令来打开另一个外壳,在其中可以键入特定命令。 在该外壳中,我想循环运行另一个命令。 更具体地说-在我的示例中,它看起来像这样:
> openssl s_client -connect 10.10.10.10:10000 ### this is the first command
CONNECTED(00000003) ### some output
(...)
### now i'd like to type 'R' in a loop (R means renegotiate)
最好的方法是什么? 预先感谢您的任何帮助
像这样子过程。
import subprocess
cmd = 'ls -la'
subprocess.call(cmd.split(), shell=False)
因此,在您的情况下,将是这样的:
import subprocess
connect = 'openssl s_client -connect 10.10.10.10:10000'
subprocess.call(connect.split(), shell=False)
while (something):
subprocess.call('R', shell=False)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.