You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 28, 2024. It is now read-only.
I am using paramiko-expect on a to execute some commands and get their corresponding exit_code. The code below works perfectly fine with 0.3.0, but it does not work with the latest one. In the latest version current_output_clean has some leftovers from the previous command.
Any pointers how to fix it or any other better way to achieve what i am trying to do?
Note: I want to run lot of commands over a period of time and I dont want to establish a ssh connection everytime i run a command, I want a way to use an existing session but just execute a command and get its output and exit code.
Thanks in Advance,
client: PK.SSHClient = PK.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(PK.AutoAddPolicy())
client.connect(hostname=host, username=user, password=passwd, port=port)
shell = SSHClientInteraction(client, timeout=timeout, display=display, output_callback=op_callback)
shell.send("some command")
shell.expect("some_prompt>", timeout=timeout, output_callback=logger)
lines = shell.current_output_clean.strip().split('\n') # This is OK.
shell.send('echo $?')
shell.expect("some_prompt")
exit_code = int(shell.current_output_clean.strip()) # This is NOT OK!!
I am using paramiko-expect on a to execute some commands and get their corresponding exit_code. The code below works perfectly fine with 0.3.0, but it does not work with the latest one. In the latest version
current_output_cleanhas some leftovers from the previous command.Any pointers how to fix it or any other better way to achieve what i am trying to do?
Note: I want to run lot of commands over a period of time and I dont want to establish a ssh connection everytime i run a command, I want a way to use an existing session but just execute a command and get its output and exit code.
Thanks in Advance,