Command line to get output on a file


Results 1 to 12 of 12

Thread: Command line to get output on a file

  1. #1
    Join Date
    Jul 2003
    Posts
    2,021

    Command line to get output on a file

    Hi folks,

    On Konsole window I started Gnomemeeting with;

    $ LC_ALL=C gnomemeeting -d4

    and then connected it to a remote self-testing site on Gnomemeeting device. All output were printed on the Konsole window.

    I tried with following command line in anticipation to get the output to a file without success;

    $ LC_ALL=C gnomemeeting -d4 > /path/to/record.txt.

    Only an empty file was created. Please advise what will be the correct command line to be used.

    TIA

    B.R.
    satimis

  2. #2
    Join Date
    Sep 1999
    Posts
    3,202
    There are 2 output streams - stdout and stderr. The redirect you used was just for stdout. Try

    LC_ALL=C gnomemeeting -d4 1> stdout.log 2> stderr.log

    stdout.log should still be empty, stderr.log should have all your stuff in it.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,021
    Hi ph34r,

    Tks for your advice.

    LC_ALL=C gnomemeeting -d4 1> stdout.log 2> stderr.log

    stdout.log should still be empty, stderr.log should have all your stuff in it.
    Why stdout.log is empty?

    I tried following command lines respectively to get printout displayed on Konsole
    Code:
    $ LC_ALL=C gnomemeeting -d4 '1> | tee /home/satimis/Working/stdout.log' '2> tee /home/satimis/Working/stderr.log' 
    
    $ LC_ALL=C gnomemeeting -d4 1'> | tee /home/satimis/Working/stdout.log' 2'> tee /home/satimis/Working/stderr.log'    
    
    $ LC_ALL=C gnomemeeting -d4 `1> | tee /home/satimis/Working/stdout.log` `2> tee /home/satimis/Working/stderr.log`
    printout continously displayed on Konsole but no files created. Please advise. TIA

    B.R.
    satimis

  4. #4
    Join Date
    Sep 2002
    Location
    Valencia, California
    Posts
    436
    gnomemeeting &> logfile.log

    Doing &> will redirect all output to a file.

  5. #5
    Join Date
    Apr 2003
    Location
    Buenos Aires, Argentina
    Posts
    4,219
    Quote Originally Posted by JThundley
    gnomemeeting &> logfile.log

    Doing &> will redirect all output to a file.
    That would output to a file all? including errors?

    I know that to output all (including errors) you have to:

    gnomemeeting > logfile.log 2>&1
    djserz.com.ar
    "All the drugs in this world won't save you from yourself..."

  6. #6
    Join Date
    Sep 2002
    Location
    Valencia, California
    Posts
    436
    Quote Originally Posted by serz
    That would output to a file all? including errors?
    yep


    command > file is for stdoutput
    command 2> file is for stderr
    command 2>&1 redirects stderr to stdout
    command &> redirects both stdout and stderr to a file.

    from man bash:
    Redirecting Standard Output and Standard Error
    Bash allows both the standard output (file descriptor 1) and the standard error output (file descriptor 2) to be redirected to
    the file whose name is the expansion of word with this construct.

    There are two formats for redirecting standard output and standard error:

    &>word
    and
    >&word

    Of the two forms, the first is preferred. This is semantically equivalent to

    >word 2>&1

  7. #7
    Join Date
    Apr 2003
    Location
    Buenos Aires, Argentina
    Posts
    4,219
    Cool, thanks!
    djserz.com.ar
    "All the drugs in this world won't save you from yourself..."

  8. #8
    Join Date
    Jul 2003
    Posts
    2,021
    HI JThundley,

    Tks for your advice.

    command > file is for stdoutput
    command 2> file is for stderr
    command 2>&1 redirects stderr to stdout
    command &> redirects both stdout and stderr to a file.
    all worked except;

    command 2>&1

    "2>&1" has to be placed at the end of the command line

    Code:
    $ LC_ALL=C gnomemeeting -d4 > /path/to/stdout_to_stderr.log 2>&1
    B.R.
    satimis

  9. #9
    Join Date
    Jul 2003
    Posts
    2,021
    Hi folks,

    What will be the correct syntax to have the stdout.log and stderr,log created in separate files while the printout still displaying on Konsole

    I tried follows;

    1)
    $ LC_ALL=C gnomemeeting -d4 2>&1 | tee /path/to/stdout_to_stderr.log
    It worked, printout displaying on Konsole, but only one file created.

    2)
    $ LC_ALL=C gnomemeeting -d4 1> /path/to/stdout.log 2> /path/to/stderr.log
    2 files created without printout on Konsole window.

    TIA

    B.R.
    satimis

  10. #10
    Join Date
    Apr 2003
    Location
    Buenos Aires, Argentina
    Posts
    4,219
    Hm... I'm not sure if you can still display it on the console if you're redirecting its output..

    You could do something like:

    $ LC_ALL=C gnomemeeting -d4 1> /path/to/stdout.log 2> /path/to/stderr.log && cat /path/to/stdout.log

    But that's just a work-around.
    djserz.com.ar
    "All the drugs in this world won't save you from yourself..."

  11. #11
    Join Date
    May 2005
    Posts
    16
    I'd do it like so:

    $ cmd 1>stdout.log 2>stderr.log & tail -f stdout.log stderr.log

    Then you get the output in real time.

  12. #12
    Join Date
    Jul 2003
    Posts
    2,021
    Hi jacobb,

    Tks for your advice.

    $ cmd 1>stdout.log 2>stderr.log & tail -f stdout.log stderr.log
    It worked for me here.

    B.R.
    satimis

Posting Permissions

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