PDA

View Full Version : Shell Scripting...redirecting executable output?



Kleid-0
05-12-2005, 10:10 PM
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??


outnow=`gcc -ansi -pedantic -Wall /home/psycho/Programming/Library/alphalib/etl.c $input -lm -lsfl`

echo "This is output: $outnow"
exit

Salem
05-13-2005, 01:07 AM
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

a=`gcc prog.c 2>&1`

Kleid-0
05-13-2005, 10:50 AM
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!!