Remote script execution with Python ...

Robert Gahan gahanr at gofree.indigo.ie
Wed Mar 7 20:42:17 CET 2001


Thanks Ben.

os.popen2 is not available to windows programmers but
win32pipe came to the rescue !!. win32pipe I think is available
from the following location
http://www.activestate.com/Products/ActivePython/win32all.html

Got something like the following to work ....

import win32pipe

stdin, stdout = win32pipe.popen2("rsh <hostname> -l <username>
<scriptname>", "t")
stdin.write("<whatever you want to write to stdin !!>")
print stdout.readlines() # This will print the result.

Regards,
Robert.

Ben Hutchings <ben.hutchings at roundpoint.com> wrote in message
news:ulmqil8qu.fsf at roundpoint.com...
> "Robert Gahan" <gahanr at gofree.indigo.ie> writes:
>
> > Hi there,
> >
> > I have installed python on a Windows PC and I am looking to
> > remotely execute a script on a UNIX box from a python program.
> > I need to be able to pipe a "y" to stdin also. Is there a windows
> > equivalent of the unix "rexec" that could help me ?. What is the
> > most appropriate way of doing this ?.
>
> You might be able to do this with something like:
>
>     script_in, script_out = os.popen2("rsh otherhost -c myscript")
>     print >>script_in 'y'
>     result = script_out.readlines()
>
> Windows 2000 includes an rsh client but I'm not sure about other
> versions of Windows.  You might want to use ssh instead for greater
> security.
>
> --
> Any opinions expressed are my own and not necessarily those of Roundpoint.





More information about the Python-list mailing list