Capture file descriptors while running an external program

Discussion in 'Python' started by, Nov 25, 2006.

  1. Guest

    >I have a problem with the module subprocess!
    >The problem is that the external software that I am running under
    >subprocess.Popen opens stdin, stdout, stderr, and other file descriptors to
    >write and read in the hard drive.

    As many other programs...

    >I know how to capture stdin, stdout and stderr, what I cannot do is to capture
    >the other file-descriptors. Is there any way to wrap those non-standard file
    >descriptors and make them write and read from a specific object that I define?
    >I know that I can use tmp files to do that, but i would like something running
    >without tmp files.

    I'm not sure what you mean by "non-standard file descriptors". The
    other program is free to open, read, write, etc any file he wants -
    are you trying to trap any file operation it may want to do?
    You *could* do such things -google for "code injection" and "API
    hooking"- but I doubt it's what you really want.

    Gabriel Genellina
    Softlab SRL

    Hi Gabriel!

    When I wrote "non-standard file descriptors", I meant the file descriptior which
    are pointed to files in the hardrive.
    What I would like to do is not to trap any file operation, but instead intercept
    that file operation, i.e. I would like the output of the external program to
    don't be writen in a file (its normal behavior), but instead be sent to any
    variable in my program.
    I know the name of the file where the external program will write the output.. I
    pass its name along the command line.

    Joao Figueiras


    O SAPO já está livre de vírus com a Panda Software, fique você também!
    Clique em:
    , Nov 25, 2006
    1. Advertisements

  2. On Sat, 25 Nov 2006 13:38:33 +0000, declaimed the
    following in comp.lang.python:

    > --
    > Gabriel Genellina
    > Softlab SRL

    Please learn to trim your replies... Your client quoted the original
    a signature block (without prefacing any quoting indicators), and your
    response is written completely UNDER that quoted signature. Many clients
    are designed to NOT quote signature blocks (ie, they stop quoting when
    they see "\n-- \n"). I had to play tricks with cut&paste to get your
    reply quoted...

    > I know the name of the file where the external program will write the output. I
    > pass its name along the command line.

    If the OS permits, define a named pipe that the external program
    will write to, supply that name as the "output file name", and then open
    that same named pipe for reading in your program.
    Wulfraed Dennis Lee Bieber KD6MOG

    (Bestiaria Support Staff: )
    Dennis Lee Bieber, Nov 25, 2006
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gordon Beaton

    Re: Running out of file descriptors

    Gordon Beaton, Jul 24, 2003, in forum: Java
    Gordon Beaton
    Jul 24, 2003
  2. Replies:
  3. Replies:
  4. JG
    Lawrence Kirby
    Feb 8, 2005
  5. Rex Gustavus Adolphus

    how to see how many open file descriptors my program has?

    Rex Gustavus Adolphus, Mar 4, 2004, in forum: Perl Misc
    Mar 6, 2004

Share This Page