A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/083020.html below:

Help with Popen3 objects and ssh... Python 2.x

Help with Popen3 objects and ssh... Python 2.x Help with Popen3 objects and ssh... Python 2.xGilles Lenfant glenfant.nospam at bigfoot.com
Wed Apr 18 16:22:25 EDT 2001
Hi,

I need to run and get the result of a command on a remote server through an
ssh client.
I can't find the way to send the password to the server.
But I'm always asked interactively for the password through the console
despite I write the "sh.tochild.write(passwd)"

Please help !

server = 'myserver'
user = 'myself'
passwd = 'mysecret'
command = 'ls -la'

import popen2
def rmtCmd(acmd):
    ''''builds a string suited to execute a command through ssh'''
    global user, server
    return 'ssh -l %s %s %s' % (user, server, acmd)

sh = popen2.Popen3('')

if __name__ == '__main__':
    # Tests stuffs
    rcmd = rmtCmd(command)
    sh = popen2.Popen3(rcmd)
    sh.tochild.write(passwd)
    sh.wait()
    print sh.fromchild.read()

I've tried other combinations to get it working... desperately !




More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4