Find the answer to your Linux question:
Results 1 to 6 of 6
A buddy of mine is trying to format the output of "/usr/local/bin/tw_cli /c0/u0 show". Running this from the terminal outputs something like this: Unit UnitType Status %Cmpl Port Stripe Size(GB) ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2007
    Posts
    3

    Echo not preserving linebreaks?


    A buddy of mine is trying to format the output of "/usr/local/bin/tw_cli /c0/u0 show". Running this from the terminal outputs something like this:
    Unit UnitType Status %Cmpl Port Stripe Size(GB) Blocks
    -----------------------------------------------------------------------
    u0 RAID-1 OK - - - 465.761 976771120
    u0-0 DISK OK - p0 - 465.761 976771120
    u0-1 DISK OK - p1 - 465.761 976771120
    This is what it should look like. Now, we're trying to echo it to an HTML file for easy viewing, using this:
    Code:
    echo -e `/usr/local/bin/tw_cli /c0/u0 show` > /var/www/status.html
    When that happens, all the line breaks are removed. Is there any way to preserve them, or somehow add them in?

  2. #2
    Banned CodeRoot's Avatar
    Join Date
    Sep 2005
    Posts
    567
    Any reason why

    Code:
    /usr/local/bin/tw_cli /c0/u0 show > /var/www/status.html
    will not work for you?

  3. #3
    Just Joined!
    Join Date
    Mar 2007
    Posts
    3
    Oh my...always trying to do things the hard way.

    Thanks!

    One more: Is there any way to add a timestamp? We're trying to do this with a crontab, so far we have:
    Code:
    00,15,30,45 * * * * /usr/local/bin/tw_cli /c0/u0 show > /var/www/status.html
    Bah, "date" is more than enough.

  4. #4
    Linux User cyberinstru's Avatar
    Join Date
    Jan 2007
    Location
    India
    Posts
    362
    When that happens, all the line breaks are removed. Is there any way to preserve them, or somehow add them in?
    The reason is, the output does not contain escape-sequences and thus 'echo' could not detect it.
    ---------------------------------
    Registered Linux User #440311
    HI2ARUN _AT_ GMAIL _DOT_ COM
    ---------------------------------

  5. #5
    Banned CodeRoot's Avatar
    Join Date
    Sep 2005
    Posts
    567
    Quote Originally Posted by LoKe
    Is there any way to add a timestamp?
    Add a timestamp to what? The data contained in 'status.html'?

  6. #6
    Just Joined!
    Join Date
    Mar 2007
    Posts
    3
    Quote Originally Posted by CodeRoot
    Add a timestamp to what? The data contained in 'status.html'?
    Pretty much. Basically he just wanted to know when the check was done. I'm a little confused as to why he wants this, since it's run by a crontab hourly, and the contents are replaced each time. Kind of pointless, I'd think.

Posting Permissions

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