Find the answer to your Linux question:
Results 1 to 4 of 4
To All: I'm a newbie to scripting in Linux (although I began coding 100 years ago in assembler on a 701!). I want to write a script that will run ...
  1. #1
    Just Joined!
    Join Date
    Mar 2007
    Location
    San Jose, CA
    Posts
    3

    Redirecting stdout to a file AND a terminal window

    To All:

    I'm a newbie to scripting in Linux (although I began coding 100 years
    ago in assembler on a 701!).

    I want to write a script that will run a monster math executable (maybe
    2-3 days wall time) and scroll its stdout to both a file and a terminal
    window (either X-windows or Konsole) so I can watch what's going on at
    the same time the good stuff is scrolled to a file, all this without
    getting tangled up in Tk/Tcl or Perl or "xwidgets" and the like. The
    best I can come up with is something like the following (BTW, my OS is
    SUSE 10.1 with KDE as the desktop on a big Linux box, and assume I've
    already written a debugged script called MyBigNumberCruncher.sh in
    bash):

    Manually open from the KDE Desktop a Konsole 1 (or an equivalent
    X-window) and type:
    touch output.out
    tail -f output.out

    Then go back to the desktop, and manually open a second Konsole (2) and
    type
    ./MyBigNumberCruncher.sh > output.out

    (all this in a common directory) and then sit back at watch the numbers
    stream by on Konsole 1 a la The Matrix.

    Surely, there's a better way! Oh, BTW, I haven't figured out how to
    launch from one console window a second on a separate thread (that
    is, without having to go back to the KDE desktop) within the same
    script. Do I have to set a separate "non-child" PID? (which I don't know how to do).

    Life was a lot simpler under APL.

    Thanks, -Old Timer

  2. #2
    Banned CodeRoot's Avatar
    Join Date
    Sep 2005
    Posts
    567
    You might want to check into:

    Code:
    man tee

  3. #3
    Just Joined!
    Join Date
    Mar 2007
    Location
    San Jose, CA
    Posts
    3

    Thanks

    Yeah, I looked into this before while goolgling around...can't find "tee" in my SUSE distro...or anywhere else.

  4. #4
    Just Joined!
    Join Date
    Mar 2007
    Location
    San Jose, CA
    Posts
    3

    Correction

    Before making my first post, I had found some examples of "tee" but they used the Korn and C shells. When I "maned" tee on my SUSE distro, it didn't surface, so I assumed it was not part of bash. However, "info" found it and it does work, so thanks. Nonetheless, I do like the idea of a separate window, and someday I'll write an "elegant" X-windows version of touch, tail, etc.

Posting Permissions

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