in reply to Long Process Waits Until End to Display Results

There are two places buffering could be happening. First, it could be in your script; I don't know what your $cache object does, but make sure whenever your actually print the output that $| is set to a true value.

Second, it could be in the $my_long_process program. Many programs, and the default stdio library, buffer output unless it's to a tty. If that's the case with $my_long_process program, it wouldn't buffer output when you ran it from the command-line (because it was connected to a tty), but would when run from your program. You might be able to test by running:

$my_long_program |cat
to see if it buffers output then.

If that's the case, finding an option to cause the program to display output immediately is the easiest solution; the other option is to connect it to a pseudo-tty, with something like Expect.

Replies are listed 'Best First'.
Re^2: Long Process Waits Until End to Display Results
by C_T (Scribe) on Dec 07, 2004 at 18:26 UTC
    make sure whenever your actually print the output that $| is set to a true value.

    I have done this. Like you, this is something I used in most of my scripts.

    Second, it could be in the $my_long_process program. Many programs, and the default stdio library, buffer output unless it's to a tty. If that's the case with $my_long_process program, it wouldn't buffer output when you ran it from the command-line (because it was connected to a tty), but would when run from your program. You might be able to test by running: $my_long_program |cat

    It still gave me real-time feedback when run piped into cat as you suggested.

    CT

    Charles Thomas
    Madison, WI