Open mshazor11 opened 4 years ago
@mshazor11 can you share a code snippet ? paramiko-expect
isn't closing the connection, cloud be that ssh server is timing out, and then you need to make sure that isn't happening.
see thing like this: https://www.thegeekdiary.com/how-to-stop-ssh-session-from-getting-timed-out/
Hello Fruch Thanks for your reply:My code is as follows: ** This is class i created to use in other python file**8 import re import paramiko from paramiko_expect import SSHClientInteraction
class myClass:
def __init__(self):
self.interact = None
def EOL(self):
client = paramiko.SSHClient()
# Set SSH key parameters to auto accept unknown hosts
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(IP Address, username='****', password='******')
self.interact = SSHClientInteraction(client, timeout=40, display=True)
self.interact.send('sudo ./HD Tool')
self.interact.expect('End of Main Menu')
return(self.interact)
my=myClass() my.EOL()
This is another python file where i am using this python class:
import re import paramiko import time from paramiko_expect import SSHClientInteraction from myClass4 import my
my.interact.send('18') my.interact.expect('End of BMS Battery') my.interact.send('4') my.interact.expect('End of BMS Battery')
I am getting problem is when i run this first time , I am doing sudo in HD tool Program and I am entering in 18 submenu of HD tool. I am worried when i run another python file which is doing something inside of 18 submenu . i donot want to start from inital like ssh into remote server , sudo HD tool then entering 18 submenu. In another python file i want to do only giving command related to 18 submenu .but it giving me error. I am trying to replicate tmux session so i donot need to do ssh and rerun HD tool again and again. I will lower my software capability.
I am trying to ssh into remote server. I run some program which is like menu application. I went into menu 1 which has sub menu from 1 to 10. If i need to leave this connection and want to come back and want to join like where i was before. I am unable to do this . As Paramariko expect is closing connection after executing one set of command