Results 1 to 5 of 5

Thread: format stdout

  1. #1
    Join Date
    Jun 2008
    Location
    As. - Paraguay - GMT -4
    Posts
    95

    Default format stdout

    how can I update a text line without clearing the screen?

    I want to show a progress info but seems impossible to update a line to increase the percent number of my script.

    I always clear the screen and then print the data updated in the same position but this solution is dirty and I don't like it.

    Every program I use use this feature and it would be very useful to me.

    I use Perl and C++.

    Thanks.
    Last edited by castord; 20-Jun-2008 at 10:07. Reason: forgot mention the programming language

  2. #2
    ab@novell.com NNTP User

    Default Re: format stdout

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    For a code reference look at how the 'rpm' command uses a progress bar
    for installations of packages with the -v (verbose) switch. Other quick
    info:

    http://thesweeheng.wordpress.com/200...-bash-scripts/
    http://www.wellho.net/resources/ex.php4?item=p210/paws

    Found a lot of hits via Google.

    Good luck.






    castord wrote:
    | how can I update a text line without clearing the screen?
    |
    | I want to show a progress info but seems impossible to update a line to
    | increase the percent number of my script.
    |
    | I always clear the screen and then print the data updated in the same
    | position but this solution is dirty and I don't like it.
    |
    | Every program I use use this feature and it would be very useful to me.
    |
    | I use Perl and C++.
    |
    | Thanks.
    |
    |
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFIW+ci3s42bA80+9kRAh+gAJsEmggFkG/DP7b2v591AIavd6GRygCfTenQ
    xF9O8jk1eLpgCl9d3ywPm/c=
    =6RLU
    -----END PGP SIGNATURE-----

  3. #3
    Join Date
    Jun 2008
    Location
    Frisco, TX
    Posts
    1,233

    Default Re: format stdout

    On Fri, 2008-06-20 at 17:16 +0000, castord wrote:
    > how can I update a text line without clearing the screen?


    The "right" way is to query the terminal capabilities database
    for the appropriate value (man terminfo).

    So, for example, consider:
    echo "hello $(tput cr)H"




  4. #4
    Join Date
    Jun 2008
    Location
    Frisco, TX
    Posts
    1,233

    Default Re: format stdout

    On Fri, 2008-06-20 at 17:58 +0000, cjcox wrote:
    > On Fri, 2008-06-20 at 17:16 +0000, castord wrote:
    > > how can I update a text line without clearing the screen?

    >
    > The "right" way is to query the terminal capabilities database
    > for the appropriate value (man terminfo).
    >
    > So, for example, consider:
    > echo "hello $(tput cr)H"


    Oh.. and obviously you can query terminal capabilities from
    other languages, I just used shell out of convenience.

    Capabilities can include all sorts of cursor movements and
    even the setting of colors and character definitions, etc.

    Popular library to use is curses (ncurses). It's a higher
    level library than includes things to make terminal based
    windows, scrolling, etc.





  5. #5
    Join Date
    Jun 2008
    Location
    As. - Paraguay - GMT -4
    Posts
    95

    Default Re: format stdout

    Thank you for the quick answer. I'll try both solutions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •