[BangPypers] Redirecting output to a string
kartheekpn at yahoo.co.in
Wed Mar 19 09:39:35 CET 2008
Thanks a lot, that worked :)
Pythonic <pythonic at gmail.com> wrote: You may want to try commands module
cmd = 'ls'
status, output = commands.getstatusoutput(cmd)
Pavithra Hanchagaiah wrote: Hey Kartheek, Â
execv() doesnât return any value. You can either try using os.popen() variants for the requirement or redirect stdout to file.
From Python Docs:
path, arg0, arg1, ...)
path, arg0, arg1, ..., env)
file, arg0, arg1, ...)
file, arg0, arg1, ..., env)
path, args, env)
file, args, env)
These functions all execute a new program, replacing the current process; they do not return.
From: bangpypers-bounces at python.org [mailto:bangpypers-bounces at python.org] On Behalf Of KartheeK
Sent: Wednesday, March 19, 2008 8:52 AM
To: bangpypers at python.org
Subject: [BangPypers] Redirecting output to a string
I am trying to access the contents of a file in a remote machine and store the contents in string.
os.execv(ssh, [ssh, "-l", user, ip] + ['cat /tmp/temp.conf']
works but displays the output on to the screen.
to_be_analysed_txt = os.execv(ssh, [ssh, "-l", user, ip] + ['cat /tmp/temp.conf']
but that does not work out.
BangPypers mailing list
BangPypers at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the BangPypers