1
コマンド実行後のCLIプロンプトでの応答方法(yes/y)私はコマンド実行のためにparamikoを使用しています。以下はCLIプロンプトで(yes/y)に答えるにはどうすればいいですか? (パラミコリモート接続)
は、私のコードの一部です:
try:
conn2 = ssh.connect(dn_name,
username="username",
password="password",
allow_agent=True,
look_for_keys=False
)
if conn2 is None:
stdin, stdout, stderr = ssh.exec_command("acidiag touch clean; reload")
time.sleep(10)
# Here I need to add a statement for answering YES
# to the above command that I gave.
output = stdout.read()
print output
if output:
ssh.close()
else:
stdin, stdout, stderr = ssh.exec_command("exit")
私は生地や他のモジュールについて読んしかし、私はそれはコードの私の作品を動作させる方法を見つけ出すことができませんでした。
stdin, stdout, stderr = ssh.exec_command("acidiag touch clean; yes | reload")
は、おそらくそれは、ユーザーの入力を要求し、具体的reload
コマンドです:
'stdin.write(" yes \ n ")' –