[python-win32] How do I re-assign stdin and stdout
David Rock
david at graniteweb.com
Fri Jul 23 21:56:11 CEST 2004
* Greg Baryza <baryza at intersystems.com> [2004-07-23 12:53]:
> Sorry for the newbie question, but...
>
> So far I have been creating scripts that automate command invocations and
> start up Windows apps just fine. Now, however, I wanted automate some
> Perforce commands. Perforce has an option that takes writes its command
> output as a marshaled Python dictionary. This requires me to route stdout
> to a file.
>
> I have created a file using win32file and gotten back a file handle. I
> have assigned that file handle to the hStdOutput item in STARTUPINFO. I
> have passed the STARTUPINFO to the win32process.CreateProcess method. Yet,
> the output does not get written to the file.
>
> I have tested various combinations of create and sharing options, but
> nothing seems to work. There is obviously some detail I am missing. Can
> someone give me the nudge I need to get over this hurdle?
The simplest way to redirect stdout to a file is something like this:
print >>file, "what you want to print(write)"
This may not be quite what you are looking for, though.
--
David Rock
david at graniteweb.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-win32/attachments/20040723/fac155f2/attachment.pgp
More information about the Python-win32
mailing list