I would suggest you stick with commendtoexecute 1 >> logfile.log 2 >> errorfile.log doing 2>&1 1>>everything.log On Mon, Mar 14, 2011 at 10:45 PM, Bryan O'Neal < Bryan.ONeal@theonealandassociates.com> wrote: > Ok - if I want to direct stranded out, standard error, or both to a > file I can do that. If I want to redirect standard out to a variable > for latter use, I can do that. But how do I redirect standard error to > a variable? > > Example: > > function fun1() > { > val1=$(DoSomething with $1) > if [[ $? -eq 1 ]]; then > echo "DoSomething failed on value $1" >> logfile.log > return 1 > else > if [[ $val1 some test ]]; then > echo "Condition met" >> logfile.log > val2=$(DoSomethingElse with something and $val1 and $1) > echo $val2 > return 0 > else > echo "Condition not met" >> logfile.log > return 1 > fi > fi > } > > fun1 somevalue > > > > So this is fine and good - but what if I want to know what the error > was from a bad call to DoSomething - Further more what if instead of > using a simple >> logfile.log I am using a complex function that > correlated messages and creates a human readable log file? I would 1) > spam roots email, and 2) lose the information as to what went wrong > and where? I want to store std error into a variable (same or > diffident var from expected output) so I can choose how to handle it. > > > On of the things I have done is started to work on a logger4Bash > function. It took a few min and has deferent log levels, deferent log > files, tags, formatting, etc. Problem is what to do when information > is spawned to standard out instead of being stored in a var I can > manipulate latter. > --------------------------------------------------- > PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us > To subscribe, unsubscribe, or to change your mail settings: > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss > -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Nathan England I believe in the Constitution and the 4th Amendment. I am innocent and have nothing to hide, but NO agent of the state crosses my threshhold without a valid warrant signed by a judge and properly submitted. If we fail to exercise our rights, we lose them.