[Tutor] Popen help?
Danny Yoo
dyoo@hkn.eecs.berkeley.edu
Mon, 10 Dec 2001 18:30:16 -0800 (PST)
On Mon, 10 Dec 2001, VanL wrote:
> I'm trying to get the output of a script that prints to stdout. The
> problem is, the script is on another server.
>
> Can I use popen to ssh to another server, run a command, and get the
> output?
Yes, we can use popen() with ssh.
Many people don't realize that the 'ssh' command can be used like 'rsh',
so we can do something like this:
###
>>> import os
>>> my_bash_profile = os.popen('ssh aztec ls -l .bash_profile').read()
>>> my_bash_profile
'-rw-r--r-- 1 dyoo users 354 Aug 23 12:04 .bash_profile\n
###
Hope this helps!