[BangPypers] Redirecting output to a string

Pavithra Hanchagaiah pavithra.hanchagaiah at thirdbrigade.com
Wed Mar 19 06:29:11 CET 2008


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:

execl(

path, arg0, arg1, ...)

 

execle(

path, arg0, arg1, ..., env)

 

execlp(

file, arg0, arg1, ...)

 

execlpe(

file, arg0, arg1, ..., env)

 

execv(

path, args)

 

execve(

path, args, env)

 

execvp(

file, args)

 

execvpe(

file, args, env)

These functions all execute a new program, replacing the current
process; they do not return.

 

Thanks,

Pavithra 

 

 

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

 

Hi All,

I am trying to access the contents of a file in a remote machine and
store the contents in string.

The command,
os.execv(ssh, [ssh, "-l", user, ip] + ['cat /tmp/temp.conf']
works but displays the output on to the screen.

I tried,
to_be_analysed_txt = os.execv(ssh, [ssh, "-l", user, ip] + ['cat
/tmp/temp.conf']
but that does not work out.

Regards,

KartheeK






-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/bangpypers/attachments/20080319/dceda518/attachment.htm 


More information about the BangPypers mailing list