[BangPypers] Redirection of standard output to a variable
Rishabh Manocha
rmanocha at gmail.com
Tue May 13 11:55:41 CEST 2008
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 from the scp command to
confirm this by hand (so to speak :)).
Best,
R
On Tue, May 13, 2008 at 3:18 PM, KartheeK <kartheekpn at yahoo.co.in> 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 see "100%" each time I download a config
> file and then only proceed further to process it.
>
>
> KartheeK
>
> Rishabh Manocha <rmanocha at gmail.com> wrote:
> 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.
>
> Best,
>
> R
>
> On Tue, May 13, 2008 at 2:42 PM, KartheeK wrote:
> > A typical scp transaction would result in an output as below:
> > -------------------------------------------------------
> > temp.conf 100% 23
> > 0.0KB/s 00:00
> > -------------------------------------------------------
> > I am interested in capturing the above output in a string.
> >
> >
>
> > gnuyoga wrote:
> >
> > 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 message if any
> >
> > if 0 means the command is executed sucessfully.
> > else it failed and reason why it failed will be returned.
> >
> >
> > please remember that we cannot see you monitor ;-)
> >
> > - sree
> >
> > --
> > http://picasaweb.google.com/gnuyoga
> >
> > Each soul is potentially divine. The goal is to manifest the divine by
> > controlling nature, internal or external. Do this by work or worship or
> > psychic control or philosophy by one or more, or all of these and be free.
> >
> > _______________________________________________
> > BangPypers mailing list
> > BangPypers at python.org
> > http://mail.python.org/mailman/listinfo/bangpypers
> >
> >
> > _______________________________________________
> > BangPypers mailing list
> > BangPypers at python.org
> > http://mail.python.org/mailman/listinfo/bangpypers
> >
> >
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
>
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
>
More information about the BangPypers
mailing list