How to disable output messages of the child process, in spawnv( )?
nushin
nushin2 at yahoo.com
Mon Jul 28 22:33:36 EDT 2003
Thanks Donn. I resolved the issue. If i do the following the output of
the child process is disabled:
os.spawnv(os.P_NOWAIT,'/usr/bin/python',('python hello.py >/dev/null
&'))
but, if some one needs to see the output of the child process spawned
by parent, then this does it:
os.spawnv(os.P_NOWAIT,'/usr/bin/python',('python','hello.py'),('>/dev/null
&'))
(I believe in Python tricks :-)
Regards,
Nushin
"Donn Cave" <donn at drizzle.com> wrote in message news:<1059059614.658900 at yasure>...
> Quoth nushin2 at yahoo.com (nushin):
> | Is there any trick to disable the output of a child process spawned by
> | spawnv( ) API?
>
> No.
>
> | I believe in Python and i am sure there's a way around it. Correct me
> | if i am wrong.
>
> You believe in tricks, is the problem. Read what people are telling you.
> You can redirect output of a command, you can do it Python, but the only
> way to do it in spawnv is to make spawnv execute a shell command.
>
> Donn Cave, donn at drizzle.com
>
> | grante at visi.com (Grant Edwards) wrote in message news:<3f1eddc9$0$160$a1866201 at newsreader.visi.com>...
> |> In article <db3b6d24.0307231050.74d41e66 at posting.google.com>, nushin wrote:
> |> > I'd like to disable the output of the process spawned by spawnv( )
> |> > API, but the catch is that i *have to* see the output of the parent
> |> > process making the spawnv( ) call. Has anyone done that? I have some
> |> > pointers that by using dup2( ) API i might be able to do that, any
> |> > ideas how? Also, i have to spawn as an asynch call, using P_NOWAIT,
> |> > e.g.,:
> |> >
> |> > os.spawnv(os.P_NOWAIT,'/usr/bin/python',('python','hello.py'),('>/dev/null &'))
> |>
> |> Nope.
> |>
> |> The ">" and "&" are things that a shell (like bash or ksh)
> |> handles. The python interpreter has no idea what to do with
> |> them. If you want to use ">" and "&", then spawn a shell, and
> |> pass it a command to run the python program with output
> |> redirected.
More information about the Python-list
mailing list