getting text from WinXP console
cjmaloof at gmail.com
Tue Mar 22 04:40:54 CET 2005
Thanks for the interesting suggestions!
On 21 Mar 2005 10:47:52 -0800, "Cappy2112" <cappy2112 at gmail.com>
>If you are launching it you can try using one of the python popen()
>calls to redirect the screen output to your python program.
Aha. This sounds perfect, and I don't know why it doesn't work even
with a basic command window:
>>> s = subprocess.Popen(args='c:\\WINDOWS\\system32\\command.com', stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
[[[completely blank command window appears]]]
>>> s.stdin.write('hi there')
Traceback (most recent call last):
File "<pyshell#41>", line 1, in -toplevel-
IOError: [Errno 22] Invalid argument
I'm guessing it's not the right kind of screen output, somehow? I
should try this with Unix.
Jeff Shannon <jeffshannon at gmail.com> wrote:
>Unless I'm seriously mistaken, the only way that this will be possible
>is if there's a Win32 API call that will give the correct information.
> This might be possible to find in the MSDN documentation, if it
>exists, but I suspect that it probably doesn't.
I think you're right. I did consider the select-and-copy idea, which
sounds vaguely silly but acceptable if there's a way to do it without
getting the selection area highlighted. At this point I wouldn't be
terribly stunned if it's the best alternative, actually, though an API
call would seem nicer. I'll see if I can turn anything up in the MSDN
library. Peter's advice to ask about this on a Windows list is
probably wisest; I'll post again if I figure it out.
I refuse on principle to do a text -> image -> text conversion, clever
though it is. :)
Lucas Raab <dotpyFE at gmail.com> wrote:
>If you're looking to do this from Python then do "python <appname.py> >
>output.txt" only without the quotes. AFAIK, this only works on Windows.
>Correct me if it works from Linux or another OS.
I do this all the time in Unix and had no idea it worked in Windows;
it's not quite what I need but still good to know!
Thanks to everybody for all the help.
More information about the Python-list