0

I am trying to run two commands in root user. command_1 is running in root and command_2 is running outside root.

import paramiko
import sys
import os
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('hostname', username='username',password='password')
stdin, stdout, stderr = ssh.exec_command("sudo -i command_1 command_2")
output = stdout.read()
print output

I tried stdin, stdout, stderr = ssh.exec_command("sudo -i command_1;command_2") but no use.

1 Answer 1

1

Using the "&" operator should work.

stdin, stdout, stderr = ssh.exec_command("sudo -i command_1 & sudo -i command_2")
Sign up to request clarification or add additional context in comments.

1 Comment

stdin, stdout, stderr = ssh.exec_command("sudo -i command_1 & sudo -i command_2") is working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.