Announcement

Collapse
No announcement yet.

prog to accept piped input and filter

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tom Hanlin
    replied
    Actually, I'm not clear on why myprog.exe doesn't find the end of the file.
    Does it loop UNTIL EOF(filenr) or some such? Perhaps it would help if you
    showed an excerpt of the code involved.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Michael Mattias
    replied
    Under MS-DOS, you might be able to use a TSR program which pops up (on timer?), reads and parses the screen, saves the result to a file, then goes back to sleep.

    If you are looking for intercept all keystrokes, POPUP INTERRUPT would be indicated, but PB already uses interrupts 8, 9 &h10, &h13, &h17, &h21 and others, so doing a keyboard trap this way seems to be not possible.

    Maybe someone else knows (remembers?) how to do a PB/DOS TSR which captures all keystrokes, or maybe you can use some preexisting MS-DOS "keystroke recorder" program.

    MCM


    Leave a comment:


  • Sebastian Groeneveld
    replied
    Hi David,

    When you want to pipe the output from one program to the input
    from another, a temporary file is used to store this data. The
    two programs will never run simultaneously and so this answers
    your question about which program has control of the keyboard
    while file123.exe is waiting for a 'Q' to be pressed; that must
    be file123.exe itself. Once it has finished execution, myprog.exe
    is launched, which reads its input (stdin) from the created
    temporary file.

    I think that:
    . file123.exe | myprog.exe

    could also be written as:
    . file123.exe > tempfile
    . myprog.exe < tempfile

    However, this does not solve your problem, but only makes it
    worse... I was wondering, when 'Q' is pressed while file123.exe
    is running and giving output, does it exit then immediately, or
    will it only read the keystroke at the end of output? If that's
    the case, you could pipe a 'Q' to the stdin of file123.exe
    Like this:
    . echo Q | file123.exe | myprog.exe

    Good luck!

    ------------------
    Sebastian Groeneveld
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • David Baker
    replied
    Originally posted by Tom Hanlin:
    Aliases are not allowed in the forums. Please re-register using your
    real name.
    Ok, I re-registered. Sorry about that....used to all of the other message boards that
    I go to.

    I do not have control of the file123.exe in my example. However,
    follow-up, which program has control of the keyboard, file123.exe
    or myprog.exe? Can I make myprog.exe pass a keypress to file123.exe
    via a buffer or in some other form? file123.exe will output info
    to the screen until the "Q" is pressed...then it will exit.

    Thanks for your help..

    David



    ------------------

    Leave a comment:


  • Tom Hanlin
    replied
    Aliases are not allowed in the forums. Please re-register using your
    real name.

    Have file123.exe send CHR$(26) to standard output when it quits. This
    should be recognized as the end of file. If you don't have control
    over file123, perhaps you could add a timer to myprog so it can time
    out after a while.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • The Zodiac
    Guest started a topic prog to accept piped input and filter

    prog to accept piped input and filter

    Hello. This is my first time posting a question,
    so please go easy on me.

    I have a pure dos program that runs from a DOS 6.22 command line.
    As this program runs, it send data to the screen (program status
    and data). This program run all the time and to quit the program,
    the user types a "Q" on the keyboard to quit the program.

    I want to write a parsing program that will capture the output from the
    screen and filter it using rules that I specify then save the
    result into a file and display the result to the screen.

    I have experiented with the OPEN "KYBD:" AS INPUT and the
    OPEN "SCRN:" AS OUTPUT statements and had some success but I am
    having trouble with typing "Q" to quit the first program and making
    *my* program end as well. I was hoping that checking EOF would do
    the trick but I don't see where the EOF character is sent where the
    first program exits.

    So....basicly the syntax is:
    file123.exe | myprog.exe

    files123.exe will output status and program data and myprog.exe
    will capture that data, parse it, apply filtering rules, save
    filtered results to file, and send filtered result to screen for
    display. I am able to create the parsing structure and saving the
    results to file. But I am just hung up on sending keyboard
    data to files123.exe (pressing "Q" to quit) and having myprog.exe
    recognize that files123.exe has quit and to return execution to
    command.com.

    I am a VB programmer by trade....but it has been awhile since I
    dusted off my non-windows programming books. Thanks for the help.

    The Zodiac

    ------------------
Working...
X