Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Question: spawn and redirection

Reply
Thread Tools

Question: spawn and redirection

 
 
Ladvánszky Károly
Guest
Posts: n/a
 
      02-13-2004
On Windows, what is the proper way to spawn an executable and redirect its
stdout and stderr.
Thanks for any help,

Károly


 
Reply With Quote
 
 
 
 
Ladvánszky Károly
Guest
Posts: n/a
 
      02-13-2004
I'd like to redirect the program output into a file.

"Peter Hansen" <(E-Mail Removed)> az alábbiakat írta a következo
hírüzenetben: http://www.velocityreviews.com/forums/(E-Mail Removed)...
> "Ladvánszky Károly" wrote:
> >
> > On Windows, what is the proper way to spawn an executable and redirect

its
> > stdout and stderr.

>
> Redirect them where? The answer might well be different (e.g. os.system

vs.
> os.popen) if you are redirecting them to a file versus redirecting them

back
> to the calling program.
>
> -Peter



 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      02-13-2004
"Ladvánszky Károly" wrote:
>
> On Windows, what is the proper way to spawn an executable and redirect its
> stdout and stderr.


Redirect them where? The answer might well be different (e.g. os.system vs.
os.popen) if you are redirecting them to a file versus redirecting them back
to the calling program.

-Peter
 
Reply With Quote
 
anton muhin
Guest
Posts: n/a
 
      02-13-2004
Ladvánszky Károly wrote:
> On Windows, what is the proper way to spawn an executable and redirect its
> stdout and stderr.
> Thanks for any help,
>
> Károly
>
>



os.spawnv(os.P_NOWAIT, r'c:\WINNT\system32\cmd.exe', ('/C dir > dir.txt',))

does a trick for me.

regards,
anton.
 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      02-13-2004
"Ladvánszky Károly" wrote:
>
> I'd like to redirect the program output into a file.


I'd just us os.system then, as in

os.system('command >somefile')

-Peter
 
Reply With Quote
 
Ladvánszky Károly
Guest
Posts: n/a
 
      02-13-2004
Thanks for your advice. os.system() is not suitable in all cases as it
always waits for the started process to terminate.

"Peter Hansen" <(E-Mail Removed)> az alábbiakat írta a következo
hírüzenetben: (E-Mail Removed)...
> "Ladvánszky Károly" wrote:
> >
> > I'd like to redirect the program output into a file.

>
> I'd just us os.system then, as in
>
> os.system('command >somefile')
>
> -Peter



 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      02-13-2004
"Ladvánszky Károly" wrote:
>
> Thanks for your advice. os.system() is not suitable in all cases as it
> always waits for the started process to terminate.
>
> "Peter Hansen" <(E-Mail Removed)> az alábbiakat írta a következo
> hírüzenetben: (E-Mail Removed)...
> > "Ladvánszky Károly" wrote:
> > >
> > > I'd like to redirect the program output into a file.

> >
> > I'd just us os.system then, as in
> >
> > os.system('command >somefile')


On Windows, you would simply to this instead then, I believe:

os.system('start command >somefile')

-Peter
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Logging stdout/stderr/stdin of an spawn process (Open4::spawn) Edgardo Hames Ruby 1 05-06-2008 08:17 PM
Logging stdout/stderr/stdin of an spawn process (Open4::spawn) Ed Hames Ruby 0 04-16-2008 04:21 PM
spawn syntax + os.P_WAIT mode behavior + spawn stdout redirection Derek Basch Python 2 01-21-2005 05:37 AM
spawn* or exec* and fork, what should I use and how ? Lingyun Yang Python 4 12-16-2004 08:35 AM
Re: How to spawn a program with redirection as it parameter Donn Cave Python 1 07-10-2003 04:48 PM



Advertisments