FAQ
I'm working in WinNT with VIM (good tool) and wanted to write some
handy filters in python to help me with routine editing chores.

I run my python command at the command line and get the output I want
printed nicely on my screen. However, if I pipe it to a file the file
comes out empty, if I pipe it to more I get nothing at all.

Does python know it's in a pipe and act differently? Does 'print' not
work right in NT? What's up?

My python is:

PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on
win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
Portions Copyright 1994-1999 Mark Hammond
Tim

Search Discussions

  • Mark Hammond at Nov 30, 1999 at 1:31 pm
    How are you executing the code? Are you just typing:

    c:\>myscript.py > out

    If so, there is a bug in the NT command prompt - you need to specify the
    full path to Python.exe on the command line, and it will work...

    Mark.

    Tim Ottinger wrote in message <3842f32d.30322451 at news.concentric.net>...
    I'm working in WinNT with VIM (good tool) and wanted to write some
    handy filters in python to help me with routine editing chores.

    I run my python command at the command line and get the output I want
    printed nicely on my screen. However, if I pipe it to a file the file
    comes out empty, if I pipe it to more I get nothing at all.

    Does python know it's in a pipe and act differently? Does 'print' not
    work right in NT? What's up?

    My python is:

    PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on
    win32
    Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
    Portions Copyright 1994-1999 Mark Hammond
    Tim
  • Tim Ottinger at Nov 30, 1999 at 6:59 pm

    On Tue, 30 Nov 1999 13:31:51 GMT, "Mark Hammond" wrote:

    How are you executing the code? Are you just typing:

    c:\>myscript.py > out

    If so, there is a bug in the NT command prompt - you need to specify the
    full path to Python.exe on the command line, and it will work...
    This works:
    c:\> myscript.py
    and produces the output I want. This, however:
    c:\> myscript.py > somefile.txt
    produces an empty text file.

    I have somewhat better luck with:
    c:\> python myscript.py > somefile.txt

    I want this to work from within vim, so it's pretty important that I
    have pipeable output. Of course, better yet would be getting the
    python stuff compiled into my vim....

    tim
  • Toby Dickenson at Dec 1, 1999 at 8:33 pm

    "Mark Hammond" wrote:
    How are you executing the code? Are you just typing:

    c:\>myscript.py > out

    If so, there is a bug in the NT command prompt - you need to specify the
    full path to Python.exe on the command line, and it will work...
    As a point of good news, this is fixed in Windows 2000.

    (so I might upgrade after all ;-)


    Toby Dickenson
    htrd90 at zepler.org
  • Paul M at Dec 1, 1999 at 8:40 pm
    Toby Dickenson wrote in message ...
    If so, there is a bug in the NT command prompt - you need to specify
    the
    full path to Python.exe on the command line, and it will work...
    As a point of good news, this is fixed in Windows 2000.

    (so I might upgrade after all ;-)

    Wow! Talk about value-added! ;-)

    --Paul
  • Gaetan Corneau at Nov 30, 1999 at 7:06 pm

    If so, there is a bug in the NT command prompt - you need to
    specify the
    full path to Python.exe on the command line, and it will work...
    This is exactly the problem I have reported a few months ago.
    I have access to many tests machines, and two of them had this problem from
    time to time.
    After a reboot, it disappeared, and I haven't seen it again since :)
    ______________________________________________________
    Gaetan Corneau
    Software Developer (Quality Assurance Team)
    BaaN Supply Chain Solutions
    http://www.baan.com
    E-mail: Gaetan_Corneau at baan.com
    Tel: (418) 266-8252
    ______________________________________________________
    "Profanity is the one language all programmers know best"
  • Gordon McMillan at Nov 30, 1999 at 7:33 pm
    Gaetan Corneau wrote:

    [Mark Hammond, to Tim Ottinger]
    If so, there is a bug in the NT command prompt - you need to
    specify the
    full path to Python.exe on the command line, and it will
    work...
    This is exactly the problem I have reported a few months ago. I
    have access to many tests machines, and two of them had this
    problem from time to time. After a reboot, it disappeared, and I
    haven't seen it again since :)
    Are you sure it's the same problem?

    As far as I know
    xxx.yyy >foo.txt
    does not work if xxx.yyy is executed through a file
    association. foo.txt will be created and empty. The executable
    associated to .yyy will have stdout and stderr connected to a
    bit bucket. Python doesn't have anything to do with it.

    - Gordon
  • Gaetan Corneau at Nov 30, 1999 at 7:42 pm
    Gordon,
    Are you sure it's the same problem?
    Thinking of it, maybe not.

    As far as I know
    xxx.yyy >foo.txt
    does not work if xxx.yyy is executed through a file
    association.
    On my machines, this *usually* works, because I use MKS Toolkit's Korn
    Shell.
    I tried with an NT "DOS" shell, and it doen't work. I wonder what's the
    difference (no, I don't use #! in my script).

    foo.txt will be created and empty. The executable
    associated to .yyy will have stdout and stderr connected to a
    bit bucket.
    Python doesn't have anything to do with it.
    I know that, of course :)
    ______________________________________________________
    Gaetan Corneau
    Software Developer (Quality Assurance Team)
    BaaN Supply Chain Solutions
    http://www.baan.com
    E-mail: Gaetan_Corneau at baan.com
    Tel: (418) 266-8252
    ______________________________________________________
    "Profanity is the one language all programmers know best"

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedNov 30, '99 at 1:21p
activeDec 1, '99 at 8:40p
posts8
users6
websitepython.org

People

Translate

site design / logo © 2022 Grokbase