2017-07-19 13 views
0

いくつかのコマンドを実行して別のシェルを開き、特定のコマンドを入力できます。そのシェルでは、別のコマンドをループで実行したいと思います。 は、具体的には - 私の例では、それは次のようになります。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) 

それを行うための最善の方法は何ですか?事前にお手数をおかけします。

+1

import subprocess cmd = 'ls -la' subprocess.call(cmd.split(), shell=False) 

だからあなたのケースでは、このようなものになるだろう – ginginsha

答えて

0

このようなサブプロセスでは、私はあなたがサブプロセスhttps://docs.python.org/2/library/subprocess.htmlを探しているのだと思い

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) 
関連する問題