Shell Scripting...redirecting executable output?

This is a discussion on Shell Scripting...redirecting executable output? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Hello everyone! For some strange reason, the variable outnow is ALWAYS empty! Even though the output of the gcc command ...

  1. #1
    UT2004 Addict Kleid-0's Avatar
    Join Date
    Dec 2004
    Posts
    656

    Shell Scripting...redirecting executable output?

    Hello everyone! For some strange reason, the variable outnow is ALWAYS empty! Even though the output of the gcc command outputed the output of its execution successfully on standard output...why is $outnow empty??

    Code:
    outnow=`gcc -ansi -pedantic -Wall /home/psycho/Programming/Library/alphalib/etl.c $input -lm -lsfl`
    
    echo "This is output: $outnow"
    exit

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535
    Probably because error messages are written to stderr, not stdout.
    Do you see the messages appear, despite your attempt to capture them?

    This works for me
    Code:
    a=`gcc prog.c 2>&1`
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    UT2004 Addict Kleid-0's Avatar
    Join Date
    Dec 2004
    Posts
    656
    Quote Originally Posted by Salem
    Do you see the messages appear, despite your attempt to capture them?[/code]
    Yes! But it worked great, thank you Salem :]..... I so knew the 2>&1 technique!! Grrraaahh!! Think corey think!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help fixing bugs in data parsing program
    By daluu in forum C Programming
    Replies: 8
    Last Post: 03-27-2003, 05:02 PM
  2. Control different DA output value!
    By Hunterhunter in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 03-13-2003, 11:11 AM
  3. Redirecting console output to sockets
    By junbin in forum Windows Programming
    Replies: 1
    Last Post: 01-19-2003, 02:15 AM
  4. help with redirecting std output & errors
    By fergie in forum Linux Programming
    Replies: 3
    Last Post: 04-22-2002, 02:59 PM
  5. redirecting the output of my profiler...
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 12-20-2001, 05:20 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21