Reputation: 107
I have to use a bash command ssh www.example.com
in my python code. What is the best library? I am having a hard time translating this to paramiko.
I have also tried subprocess library but neither of these are working for me.
subprocess.check_call(
"ssh www.example.com".format(title, description),
shell=True)
ssh=paramiko.SSHClient
def __init__(self, name):
ssh www.example.com
can someone tell me what I am doing wrong? Is there a better library to directly translate the bash command to python, in this case ssh? just to give more context, I have hitting a ssh url that generates a password which then I need to feed back into my code.
Thanks in advance.
Upvotes: 0
Views: 947
Reputation: 46
I used something like this:
c = ("ssh example.com")
ssh = subprocess.Popen(c, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, bufsize=1, universal_newlines=True, shell=True)
You can read the output with ssh.stdout
.
Upvotes: 1