Re: [BangPypers] Redirection of standard output to a variable

2008-05-13 Thread KartheeK
Hi Anand, This works for ls, I also tried it to capture ping. But for some unknown reasons it is not able to capture scp's output. The variable f is empty. KartheeK Anand Balachandran Pillai [EMAIL PROTECTED] wrote: Using os.popen for this is straight-forward. Example... [EMAIL PROTECTED]

Re: [BangPypers] Redirection of standard output to a variable

2008-05-13 Thread gnuyoga
KartheeK wrote: Hi Anand, This works for ls, I also tried it to capture ping. But for some unknown reasons it is not able to capture scp's output. The variable f is empty. KartheeK u have to get the standard error stream as well u can take a look at commands module ex: import commands

Re: [BangPypers] Redirection of standard output to a variable

2008-05-13 Thread KartheeK
Hi, I tried that too but it also for some reasons fails to capture scp output although it can capture things like ping. command.getstatusoutput returns exit code but not the string. KartheeK gnuyoga [EMAIL PROTECTED] wrote: KartheeK wrote: Hi Anand, This works for ls, I also tried it to

Re: [BangPypers] Redirection of standard output to a variable

2008-05-13 Thread gnuyoga
KartheeK wrote: Hi, I tried that too but it also for some reasons fails to capture scp output although it can capture things like ping. command.getstatusoutput returns exit code but not the string. what do u mean by scp output ? commands.getstatusoutput will give you output status and

Re: [BangPypers] Redirection of standard output to a variable

2008-05-13 Thread KartheeK
A typical scp transaction would result in an output as below: --- temp.conf 100% 23 0.0KB/s 00:00 --- I am interested in

Re: [BangPypers] Redirection of standard output to a variable

2008-05-13 Thread Rishabh Manocha
In that case, why not use what gnuyoga suggested - i.e. - commands.getstatusoutput(scp ...). If the first entry in the returned tuple is 0, the command executed successfully, if not, then it didn't :). I think you can trust python to get the correct exit code without actually parsing the output

Re: [BangPypers] Redirection of standard output to a variable

2008-05-13 Thread Anand Balachandran Pillai
This is not an easy thing to do. You can capture any error output by scp by redirecting the error stream, For example, $ scp names.txt [EMAIL PROTECTED]:/home/anand 2out.txt $ more out.txt names.txt: no such file or directory However trying to capture the output stream (with no error) does not

Re: [BangPypers] Redirection of standard output to a variable

2008-05-13 Thread Rishabh Manocha
Kartheek, It seems like what you want to do is a bit complicated - http://www.linuxquestions.org/questions/linux-general-1/how-to-redirect-the-scp-command-output-to-text-file.-629034/. Maybe if you can explain why you need the exact string that scp outputs, somebody can suggest alternatives.

Re: [BangPypers] Redirection of standard output to a variable

2008-05-13 Thread Anand Chitipothu
On Tue, May 13, 2008 at 3:18 PM, KartheeK [EMAIL PROTECTED] wrote: Hi Rishabh, My script needs to fetch some critical config files from 200+ servers, process them and put them back in place. I need to make sure at each step that I am doing the right thing. So, I though i would make sure to

Re: [BangPypers] Redirection of standard output to a variable

2008-05-13 Thread KartheeK
Hi Rishabh, My script needs to fetch some critical config files from 200+ servers, process them and put them back in place. I need to make sure at each step that I am doing the right thing. So, I though i would make sure to see 100% each time I download a config file and then only proceed

Re: [BangPypers] Redirection of standard output to a variable

2008-05-13 Thread KartheeK
Looks like that is the best available option.. Thank you all folks for your time and assistance. Regards, KartheeK Rishabh Manocha [EMAIL PROTECTED] wrote: In that case, why not use what gnuyoga suggested - i.e. - commands.getstatusoutput(scp ...). If the first entry in the returned tuple is