1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Scrolling output to single, non-scrolling line

Discussion in 'Support' started by element, Feb 8, 2011.

  1. element

    Joined:
    Jun 1, 2008
    Messages:
    30
    Likes Received:
    0
    I've got a command-line app which spits out a long, quickly scrolling output as it works. The output consists of similar, repeated lines in which some numbers are updated continuously as the app works. Is there a way to pipe this output through something (via stdin or some such), so that instead of the quickly scrolling output, I get a single, non-scrolling line with constantly updated numbers? I've seen command-line apps whose real-time output is a single, but constantly changing line.
     
  2. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    ---- Original Message ----
    From: element
    To: ESFabian@zenge.org
    Sent: Tuesday, 2011. February 8. 14:28
    Subject: [Support-t-2595] Scrolling output to single, non-scrolling line

    | I've got a command-line app which spits out a long, quickly scrolling
    | output as it works. The output consists of similar, repeated lines in
    | which some numbers are updated continuously as the app works. Is
    | there a way to pipe this output through something (via stdin or some
    | such), so that instead of the quickly scrolling output, I get a
    | single, non-scrolling line with constantly updated numbers? I've seen
    | command-line apps whose real-time output is a single, but constantly
    | changing line.

    Assuming that your command line application is a TCC batch file, replace the ECHO statement that generates the varying output with:

    echos %=rxxxx

    where "xxxx" is the data displayed by the ECHO command it replaces. The ECHOS command does not append a "new line" when completed (unlike ECHO), and the %=r sequence starts each line with a "carriage return", i.e., on the left margin.

    I use this technique often.
    --
    HTH, Steve
     
  3. element

    Joined:
    Jun 1, 2008
    Messages:
    30
    Likes Received:
    0
    Thanks, that's a good trick to know. But in this case, I don't have access to the app's code. I just get the output. Is there a pipe trick that would do the same op on stdin? That is, read stdin via a pipe, for each line add the '\r' at the beginning, drop the '\n', and print that out?
     
  4. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    ---- Original Message ----
    From: element
    | Quote:
    | Originally Posted by Steve Fabian
    || Assuming that your command line application is a TCC batch file,
    || replace the ECHO statement that generates the varying output with:
    |
    | Thanks, that's a good trick to know. But in this case, I don't have
    | access to the app's code. I just get the output. Is there a pipe
    | trick that would do the same op on stdin? That is, read stdin via a
    | pipe, for each line add the '\r' at the beginning, drop the '\n', and
    | print that out?

    Untested approach:

    application | for %x in (@con:) echos %=r%x

    Try it - it may do what you desire.
    --
    HTH, Steve
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,938
    Likes Received:
    30
    On Tue, 08 Feb 2011 21:09:11 -0500, Steve Fabian <> wrote:

    |Untested approach:
    |
    |application | for %x in (@con:) echos %=r%x
    |
    |Try it - it may do what you desire.

    That will overwrite each line but not erase the tail (which might be necessary).
    With ANSI turned on, you could erase the tail with ^e[K.

    Test it with ping.exe; it works nicely. You see one line with the "time=..."
    continually updating.

    Code:
    v:\> ping -t jpsoft.com | for %x in (@con:) echos ^r%x^e[K
    Reply from 207.7.82.31: bytes=32 time=60ms TTL=53[K
     
  6. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    ---- Original Message ----
    From: vefatica
    To: ESFabian@zenge.org
    Sent: Tuesday, 2011. February 8. 22:47
    Subject: RE: [Support-t-2595] Scrolling output to single, non-scrolling
    line

    | On Tue, 08 Feb 2011 21:09:11 -0500, Steve Fabian <> wrote:
    |
    || Untested approach:
    ||
    || application | for %x in (@con echos %=r%x

    Due to "smilies" the colon : right-parenthesis ) sequence after "con" was mangled...

    ||
    || Try it - it may do what you desire.
    |
    | That will overwrite each line but not erase the tail (which might be
    | necessary).
    | With ANSI turned on, you could erase the tail with ^e[K.

    Good point; in my own use erasing is not necessary, overwrite is always perfect.

    |
    | Test it with ping.exe; it works nicely. You see one line with the
    | "time=..."
    | continually updating.
    |
    |
    | Code:
    | v:\> ping -t jpsoft.com | for %x in (@con:) echos ^r%x^e[K
    | Reply from 207.7.82.31: bytes=32 time=60ms TTL=53[K

    Strange aftereffect: the [K shows up in the display, possibly because of the need to terminate PING with a ctrl-C or ctrl-break.
    --
    Steve
     
  7. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,938
    Likes Received:
    30
    On Tue, 08 Feb 2011 23:11:09 -0500, Steve Fabian <> wrote:

    || Code:
    || v:\> ping -t jpsoft.com | for %x in (@con:) echos ^r%x^e[K
    || Reply from 207.7.82.31: bytes=32 time=60ms TTL=53[K
    |
    |Strange aftereffect: the [K shows up in the display, possibly because of the need to terminate PING with a ctrl-C or ctrl-break.

    No, that was me, in editing my post. I pasted the command first, then the
    output line (in the wrong place), then noticed "^e[K" missing from the command
    and added it again.
     
  8. element

    Joined:
    Jun 1, 2008
    Messages:
    30
    Likes Received:
    0
    Thanks, it worked like a charm. Makes things way more readable.
     
  9. element

    Joined:
    Jun 1, 2008
    Messages:
    30
    Likes Received:
    0
    How would I implement the above as an alias? If I copy the line literally, I get the multiline ping.
    Code:
    ping2=ping -t jpsoft.com | for %x in (@con:) echos ^r%x^e[K
    I tried replacing the "^" with "%=", but it's still multiline.
    Code:
    ping2=ping -t jpsoft.com | for %x in (@con:) echos %=r%x%=e[K
     
  10. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    ---- Original Message ----
    From: element
    | Quote:
    | Originally Posted by vefatica
    | Code:
    | v:\> ping -t jpsoft.com | for %x in (@con:) echos ^r%x^e[K
    |
    | How would I implement the above as an alias? If I copy the line
    | literally, I get the multiline ping.
    |
    | Code:
    | ping2=ping -t jpsoft.com | for %x in (@con:) echos ^r%x^e[K
    | I tried replacing the "^" with "%=", but it's still multiline.
    |
    | Code:
    | ping2=ping -t jpsoft.com | for %x in (@con:) echos %=r%x%=e[K

    There indeed appears to be a problem with the X3.64 command K - it erases to EOL, but adds a new line sequence. If you don't mind clearing the screen when you begin, you can use this sequence:

    ping2=ping -t jpsoft.com | for %x in (@con:) echos %=e[J%x

    which clears the screen before each line of output, every line starts in the top left corner.
    --
    Steve
     
  11. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,938
    Likes Received:
    30
    On Wed, 09 Feb 2011 08:11:23 -0500, Steve Fabian <> wrote:

    | There indeed appears to be a problem with the X3.64 command K - it erases to EOL, but adds a new line sequence. If you don't mind clearing the screen when you begin, you can use this sequence:

    It doesn't do that outside an alias. My original example (with ping) works at
    the command line but not in an alias. I don't know why. With the escape
    sequence in it, it's hard to even see the alias.

    Aha! Even the alias works OK as long as you're not on the last line of the
    console window. In that case, apparently, the ^e[K causes a scroll (possibly a
    bug in its implementation). I used

    Code:
    v:\> alias pi `ping -t jpsoft.com | for %x in (@con:) echos
    ^r%x^e[K`
     
  12. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    ---- Original Message ----
    From: vefatica
    | Aha! Even the alias works OK as long as you're not on the last line
    | of the
    | console window. In that case, apparently, the ^e[K causes a scroll
    | (possibly a
    | bug in its implementation). I used
    |
    |
    | Code:
    | v:\> alias pi `ping -t jpsoft.com | for %x in (@con:) echos
    | ^r%x^e[K`

    Confirmed. <esc>[K incorrectly causes scrolling when on the last line of the screen, but not otherwise.
    --
    Steve
     
  13. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,187
    Likes Received:
    11
    You could also append spaces to the end.
    The other issue you'll run into is special symbols like the redirection
    symbols in the output. You'll need to use setdos /x or quote the
    output.

    If you know your output line length
    varies by 10 characters, you can append 10 spaces at the end.

    ping -t jpsoft.com | for %x in (@con) echos ^r"%x"`
    `

    Note that the colon is not necessary after @CON and
    the spaces are in back quotes.

    -Scott


    Steve Fabian <> wrote on
    02/09/2011 08:11:21 AM:


    line

    still multiline.

    command K -


     
  14. element

    Joined:
    Jun 1, 2008
    Messages:
    30
    Likes Received:
    0
    Thanks. I read the alias from an alias.lst file. So to prep the console, I first add one line, than move the cursor up.
    Code:
    ping2=echo. & echos ^e[1A & ping -t jpsoft.com | for %x in (@con:) echos ^r%x^e[K
     

Share This Page