2017-02-14 11 views
0

ssh 대화식 명령에 paramiko를 사용하고 있습니다. 모든 필요한 명령을 성공적으로 보낼 수 있습니다. 나는 하나의 문제에 붙어있다. 이 일을 자동화하는 데 도움이 필요해. 문제는 출력 중이며,이 옵션에서 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') 

답변