Capturing output with input

Discussion in 'Python' started by gopala, Oct 28, 2007.

  1. gopala

    gopala Guest

    Hi, I am pretty new to python but i do have experience with c++. As a
    part of learning exercise i wrote a python script to insert
    beautifying comments(with name, problem...) to our lab program source
    files (c language).

    The script is working for most of the cases. The problem is i also
    need to append the test output of the lab programs to the
    corresponding source files(again the output should be added as a
    beautified comment). The lab programs are interactive and very
    different from each other. Currently in the script, i am prompting the
    user(me!) to manually enter the output of the program which it to be
    inserted. I want to eliminate this tedious step.

    for eg i want "python commenter.py lab1.c" to initially prepend
    comments with my name... and then spawn lab1.exe , capture its output
    and append it with comments to lab1_com.c

    My initial attempts of using spawn.. , exec.. pipe.. failed since they
    can't capture the std input and std output continuously.
    The lab1.exe will be something like

    Enter 2 nos
    2 3
    The sum is 5

    Now i should be able to capture all these.
    Is this possible ? If so please do give me some hints on how to
    achieve this.

    Cheers,
    Gopala Krishna
     
    gopala, Oct 28, 2007
    #1
    1. Advertising

  2. En Sun, 28 Oct 2007 15:39:07 -0300, gopala <>
    escribi�:

    > My initial attempts of using spawn.. , exec.. pipe.. failed since they
    > can't capture the std input and std output continuously.
    > The lab1.exe will be something like
    >
    > Enter 2 nos
    > 2 3
    > The sum is 5
    >
    > Now i should be able to capture all these.
    > Is this possible ? If so please do give me some hints on how to
    > achieve this.


    On Linux, use the "script" command.
    On Windows, select the region to copy using the mouse and paste it onto a
    notepad file.
    I don't think Python would help here.

    --
    Gabriel Genellina
     
    Gabriel Genellina, Oct 29, 2007
    #2
    1. Advertising

  3. gopala

    gopala Guest

    On Oct 29, 9:03 am, "Gabriel Genellina" <>
    wrote:

    > On Linux, use the "script" command.
    > On Windows, select the region to copy using the mouse and paste it onto a
    > notepad file.
    > I don't think Python would help here.


    Thanks :)
    Now i just do os.system(exeFile) and i can easily copy the output
    from terminal using mouse selection.
     
    gopala, Oct 29, 2007
    #3
    1. Advertising

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. Rick Strahl [MVP]

    Capturing ASPX output from another page

    Rick Strahl [MVP], Jul 9, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    492
    Steve C. Orr, MCSD
    Jul 9, 2003
  2. Hoegje
    Replies:
    2
    Views:
    22,601
    Gianni Mariani
    Dec 5, 2003
  3. Yannick
    Replies:
    2
    Views:
    274
    Howard
    Jun 9, 2006
  4. nomihn0

    Capturing global input?

    nomihn0, Dec 6, 2007, in forum: Python
    Replies:
    4
    Views:
    285
    nomihn0
    Dec 10, 2007
  5. Replies:
    1
    Views:
    152
    Brian McCauley
    Jul 2, 2005
Loading...

Share This Page