By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,986 Members | 1,583 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,986 IT Pros & Developers. It's quick & easy.

Question: spawn and redirection

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

Károly
Jul 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"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
Jul 18 '05 #2

P: n/a
I'd like to redirect the program output into a file.

"Peter Hansen" <pe***@engcorp.com> az alábbiakat írta a következo
hírüzenetben: 40***************@engcorp.com...
"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

Jul 18 '05 #3

P: n/a
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.
Jul 18 '05 #4

P: n/a
"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
Jul 18 '05 #5

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

"Peter Hansen" <pe***@engcorp.com> az alábbiakat írta a következo
hírüzenetben: 40***************@engcorp.com...
"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

Jul 18 '05 #6

P: n/a
"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" <pe***@engcorp.com> az alábbiakat írta a következo
hírüzenetben: 40***************@engcorp.com...
"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
Jul 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.