Nov-29-2022, 02:26 PM
Hi,
I am using paramiko library to run interactive shell.
As per my requirement ,I needed to execute a command (say command3) only after executing command1 and command2 parallely.So below is my code to do same
How do i proceed now?
Thanks
I am using paramiko library to run interactive shell.
As per my requirement ,I needed to execute a command (say command3) only after executing command1 and command2 parallely.So below is my code to do same
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(HOSTNAME, port=PORT, username=USERNAME, password=PASSWORD)
connection = ssh.invoke_shell()
connection.send("cd /opt \n")
commands = """
command1
command2
"""
#Parallel execution of command1 and command2
task = [command for command in commands.split('/n')]
with concurrent.futures.ThreadPoolExecutor() as executor:
executor.map(connection.send, task)
time.sleep(1)
result1=connection.recv(600000)
time.sleep(1)
result=connection.recv_exit_status()
print(result)
#If command1 and command2 are successful ,then here i need to run command3
time.sleep(1)
ssh.close()But my above code doesnt print anything and i am not receiving any response.The code is hanging.How do i proceed now?
Thanks
