2017-02-14 19 views
0

Я использую paramiko для интерактивных команд ssh. Я могу успешно отправить все необходимые команды. Я застрял в одном вопросе. Мне нужна помощь для автоматизации этой задачи. Проблема на выходе, я получаю 4 варианта, из этих параметров мне нужно перейти к нужному параметру с помощью клавиш со стрелками, а затем нажать кнопку ввода, чтобы выбрать эту опцию. Пожалуйста, дайте мне знать, если кто-нибудь знает об этом.Интерактивный скрипт 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') 

ответ

 Смежные вопросы

  • Нет связанных вопросов^_^