logging / flushing output - Protocols

This is a discussion on logging / flushing output - Protocols ; System: C-Kermit 8.0.211 on Linux 2.6 (Ubuntu). I have a simple script that does a straightforward interactive chat with a remote system. Basically it is INPUTs and OUTPUTs, with ECHO statements describing the action (e.g. ECHO "Waiting for login:"). I ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: logging / flushing output

  1. logging / flushing output

    System: C-Kermit 8.0.211 on Linux 2.6 (Ubuntu).

    I have a simple script that does a straightforward interactive chat
    with a remote system. Basically it is INPUTs and OUTPUTs, with ECHO
    statements describing the action (e.g. ECHO "Waiting for login:").

    I use the script as a "kerbang" script (starting with
    #!/usr/local/bin/kermit +), have "set input echo on" and when I run the
    script at the terminal it works as expected, with the output from the
    remote system interspersed with the text from the ECHO statements.

    However, when I redirect the output to a file thusly:

    $ ./script.ksc > script.log 2>&1

    strange things happen. Doing a "tail -f script.log" from another
    window (or backgrounding the script and doing the "tail" from the same
    window) reveals that the output from the remote system is showing up in
    real time, but the output from the ECHO statements is not showing up
    until the script terminates.

    Why is this? It seems like the output from the input echo is going to
    a buffer that is being flushed regularly, while the output from the
    ECHO statements is going into another buffer that isn't being flushed.
    Strange.

    Any way to correct this behavior? I'd like to be able to monitor the
    progress of a background Kermit task in real time.


  2. Re: logging / flushing output

    On 2006-08-13, tomviolin wrote:
    : System: C-Kermit 8.0.211 on Linux 2.6 (Ubuntu).
    :
    : I have a simple script that does a straightforward interactive chat
    : with a remote system. Basically it is INPUTs and OUTPUTs, with ECHO
    : statements describing the action (e.g. ECHO "Waiting for login:").
    :
    : I use the script as a "kerbang" script (starting with
    : #!/usr/local/bin/kermit +), have "set input echo on" and when I run the
    : script at the terminal it works as expected, with the output from the
    : remote system interspersed with the text from the ECHO statements.
    :
    : However, when I redirect the output to a file thusly:
    :
    : $ ./script.ksc > script.log 2>&1
    :
    : strange things happen. Doing a "tail -f script.log" from another
    : window (or backgrounding the script and doing the "tail" from the same
    : window) reveals that the output from the remote system is showing up in
    : real time, but the output from the ECHO statements is not showing up
    : until the script terminates.
    :
    : Why is this?
    :
    I/O across the connection is buffered, ECHO commands are not.

    : It seems like the output from the input echo is going to
    : a buffer that is being flushed regularly, while the output from the
    : ECHO statements is going into another buffer that isn't being flushed.
    : Strange.
    :
    : Any way to correct this behavior? I'd like to be able to monitor the
    : progress of a background Kermit task in real time.
    :
    Instead of:

    ECHO "Waiting for login:"

    use:

    WRITELN ERROR "Waiting for login:"

    This writes the string to stderr, which is not buffered.

    - Frank

  3. Re: logging / flushing output

    tomviolin wrote:
    > System: C-Kermit 8.0.211 on Linux 2.6 (Ubuntu).
    >
    > I use the script as a "kerbang" script (starting with
    > #!/usr/local/bin/kermit +), have "set input echo on" and when I run the
    > script at the terminal it works as expected, with the output from the
    > remote system interspersed with the text from the ECHO statements.
    >
    > However, when I redirect the output to a file thusly:
    >
    > $ ./script.ksc > script.log 2>&1
    >
    > strange things happen. Doing a "tail -f script.log" from another
    > window (or backgrounding the script and doing the "tail" from the same
    > window) reveals that the output from the remote system is showing up in
    > real time, but the output from the ECHO statements is not showing up
    > until the script terminates.


    Recent daily builds have
    a --unbuffered command line option. This may help.

    --
    Mark Sapiro msapiro at value net The highway is for gamblers,
    San Francisco Bay Area, California better use your sense - B. Dylan


+ Reply to Thread