[BangPypers] Redirecting output to a string

KartheeK 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
 
 import commands
 cmd = 'ls'
 status, output = commands.getstatusoutput(cmd)
 print output
 
 
 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:
                                 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
   
  
 _______________________________________________
BangPypers mailing list
BangPypers at python.org
http://mail.python.org/mailman/listinfo/bangpypers

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


More information about the BangPypers mailing list