Thread: Shell Scripting...redirecting executable output?

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    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.

  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, 06: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, 12:11 PM
  3. Redirecting console output to sockets
    By junbin in forum Windows Programming
    Replies: 1
    Last Post: 01-19-2003, 03: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, 06:20 PM