Question: spawn and redirection

  • Thread starter Ladvánszky Károly
  • Start date
L

Ladvánszky Károly

On Windows, what is the proper way to spawn an executable and redirect its
stdout and stderr.
Thanks for any help,

Károly
 
P

Peter Hansen

Ladvánszky Károly said:
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
 
A

anton muhin

Ladvánszky Károly said:
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.
 
P

Peter Hansen

Ladvánszky Károly said:
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
 
L

Ladvánszky Károly

Thanks for your advice. os.system() is not suitable in all cases as it
always waits for the started process to terminate.
 
P

Peter Hansen

Ladvánszky Károly said:
Thanks for your advice. os.system() is not suitable in all cases as it
always waits for the started process to terminate.

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

os.system('start command >somefile')

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top