2017-02-14 2 views
0

私はssh対話コマンドにparamikoを使用しています。私は正常にすべての必要なコマンドを送信することができます。私は1つの問題に立ち往生しています。私はこの仕事を自動化するために誰か助けが必要です。 問題が出力され、私はこのオプションから4つのオプションを得るでしょう、私は矢印キーを使用して必要なオプションに移動し、Enterボタンを押してそのオプションを選択する必要があります。 誰かがこれについて知っていれば教えてください。SSH Paramiko-Python対話型スクリプト - リストから行をハイライトして選択する必要があります

import paramiko 
import time 
import os 


ssh=paramiko.SSHClient() 
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 
ssh.connect('server',port=22,username='user',password='pass123') 
print("connected to the linux machine from windows machine.") 

channel=ssh.invoke_shell() 

channel_data = str() 

while True: 
    if channel.recv_ready(): 
     channel_data += channel.recv(9999).decode(encoding='utf_8', errors='strict') 
     os.system('cls') 
     print("##### Device Output #####") 
     print("\n",channel_data) 
     print("\n #####################") 
    else: 
     continue 

    time.sleep(5) 

    if channel_data.endswith('[[email protected] ~]# '): 
     channel.send('somecommand\n') 
    #highlight and then press enter button to select that option. please help for below code 
    ifelse channel_data.endswith('I am trying to choose this option from the list'): 
     channel.send('\n') 

答えて

関連する問題