FAQ
i,
I was writing a script to search my mail archives. After doing the search
I'd like to start Pine from the script and view the results. In addition
after the
exit of Pine I want the script to carry on - ie the script should wait until
the pine process finishes. I've tried using the popen2 class but I get the
following error:

Traceback (most recent call last):
File "/home/rajarshi/src/misc/py/ptest.py", line 153, in ?
print p.poll()
AttributeError: 'tuple' object has no attribute 'poll'

,where p = os.popen4("pine")

But the docs say that instances of popen2 and peopn4 have the methods poll()
and wait(). I also tried os.spawn(os.P_WAIT,"pine") but then the the
program just carries on and no pine comes up.

Could somebody please tell me where I'm going wrong and how I could solve
this problem.

PS. I'm doing all this under Linux and Python 2.1
TIA,


--
-------------------------------------------------------------
Rajarshi Guha

email: rajarshi at presidency.com
web: http:/www.psynet.net/jijog

Search Discussions

  • Uwe Hoffmann at May 27, 2001 at 10:30 am

    Rajarshi Guha wrote:
    i,
    I was writing a script to search my mail archives. After doing the search
    I'd like to start Pine from the script and view the results. In addition
    after the
    exit of Pine I want the script to carry on - ie the script should wait until
    the pine process finishes. I've tried using the popen2 class but I get the
    following error:

    Traceback (most recent call last):
    File "/home/rajarshi/src/misc/py/ptest.py", line 153, in ?
    print p.poll()
    AttributeError: 'tuple' object has no attribute 'poll'

    ,where p = os.popen4("pine")
    instead use p=popen2.Popen4("pine")

    http://www.python.org/doc/current/lib/module-popen2.html
    the Popen4 objects created by popen4
    (maybe the term factory function is misleading here, i'm not sure)
    are used internally only.

    from popen2.py library module
    ...
    def popen4(cmd, bufsize=-1, mode='t'):
    """Execute the shell command 'cmd' in a sub-process. If 'bufsize'
    is
    specified, it sets the buffer size for the I/O pipes. The file
    objects
    (child_stdout_stderr, child_stdin) are returned."""
    inst = Popen4(cmd, bufsize)
    return inst.fromchild, inst.tochild
    ...
    But the docs say that instances of popen2 and peopn4 have the methods poll()
    and wait(). I also tried os.spawn(os.P_WAIT,"pine") but then the the
    program just carries on and no pine comes up.

    Could somebody please tell me where I'm going wrong and how I could solve
    this problem.

    PS. I'm doing all this under Linux and Python 2.1
    TIA,

    --
    -------------------------------------------------------------
    Rajarshi Guha

    email: rajarshi at presidency.com
    web: http:/www.psynet.net/jijog
  • Rainy at May 27, 2001 at 3:18 pm

    On Sun, 27 May 2001 11:40:44 +0530, Rajarshi Guha wrote:
    i,
    I was writing a script to search my mail archives. After doing the search
    I'd like to start Pine from the script and view the results. In addition
    after the
    exit of Pine I want the script to carry on - ie the script should wait until
    the pine process finishes. I've tried using the popen2 class but I get the
    following error:

    Traceback (most recent call last):
    File "/home/rajarshi/src/misc/py/ptest.py", line 153, in ?
    print p.poll()
    AttributeError: 'tuple' object has no attribute 'poll'

    ,where p = os.popen4("pine")

    But the docs say that instances of popen2 and peopn4 have the methods poll()
    and wait(). I also tried os.spawn(os.P_WAIT,"pine") but then the the
    program just carries on and no pine comes up.

    Could somebody please tell me where I'm going wrong and how I could solve
    this problem.

    PS. I'm doing all this under Linux and Python 2.1
    TIA,
    Wouldn't it be simpler here to just use os.system?

    --
    -------------------------------------------------------------
    Rajarshi Guha

    email: rajarshi at presidency.com
    web: http:/www.psynet.net/jijog

    --
    The point of philosophy is to start with something so simple as not
    to seem worth stating, and to end with something so paradoxical
    that no one will believe it.
  • Rajarshi Guha at May 27, 2001 at 3:36 pm
    Rainy <sill at optonline.net> wrote in message
    news:slrn9h26l1.ar2.sill at sill.silmarill.org...
    Wouldn't it be simpler here to just use os.system?
    It would if I could make my script wait for the sub process started by
    os.system to finish

    Bye,

    --
    -------------------------------------------------------------
    Rajarshi Guha

    email: rajarshi at presidency.com
    web: http:/www.psynet.net/jijog
  • Remco Gerlich at May 27, 2001 at 4:30 pm

    Rajarshi Guha <rajarshi at presidency.com> wrote in comp.lang.python:
    Rainy <sill at optonline.net> wrote in message
    news:slrn9h26l1.ar2.sill at sill.silmarill.org...
    Wouldn't it be simpler here to just use os.system?
    It would if I could make my script wait for the sub process started by
    os.system to finish
    But that's what it does by default...

    --
    Remco Gerlich
  • Thomas Wouters at May 27, 2001 at 4:43 pm

    On Sun, May 27, 2001 at 09:06:44PM +0530, Rajarshi Guha wrote:
    Rainy <sill at optonline.net> wrote in message
    news:slrn9h26l1.ar2.sill at sill.silmarill.org...
    Wouldn't it be simpler here to just use os.system?
    It would if I could make my script wait for the sub process started by
    os.system to finish
    Fortunately, that's exactly what os.system does.

    --
    Thomas Wouters <thomas at xs4all.net>

    Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
  • Martin Franklin at May 31, 2001 at 10:20 am
    All,


    Recently I have been creating and compiling 'c' extensions
    on my *nix platforms (Linux, Solaris, IRIX and yes AIX!)

    The extensions make some calls to some legacy code we have
    lying around. I make them by hacking the Python make system

    On al other platforms it compiles first time every time;-)
    on AIX however I was getting the following message from make:-


    [compo:bpse:/SRC/python/Extending/NewFileInfo/aix4]
    14 % make
    xlc -DIBMRS -O -I/usr/local/include/python2.0
    -I/usr/local/include/python2.0 -I/legacy/code/src/include
    -DHAVE_CONFIG_H -c -q32 ./NewFileInfo.c
    "/usr/include/sys/socket.h", line 76.21: 1506-247 (S) Incompatible type
    specifier "int".
    make: 1254-004 The error code from the last command is 1.


    Stop.


    So i looked in /usr/include/sys/socket.h and at line 76:-


    typedef __ulong32_t socklen_t;


    Then I tracked where it was being defined as an int........


    /usr/local/include/python2.0/config.h

    Around line 147

    /* Define to `int' if <sys/types.h> doesn't define. */
    #define socklen_t int


    The wired thing is socklen_t is not defined in sys/types.h but
    in socket.h so the comment makes no sense.

    So I removed the offending #define and it compiles without error.....



    Is this a bug and as such should I report it to the bug tracker
    at sourceforge?



    Thanks for your time,
    Martin.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMay 27, '01 at 6:10a
activeMay 31, '01 at 10:20a
posts7
users6
websitepython.org

People

Translate

site design / logo © 2022 Grokbase