Java with Unix (Redirection + Piping)

Hi,

To explain this question I will have to go into a bit of detail. I hope you don't mind.

currently I have a log handler (an already compiled c++ version) and what it does is makes a log file and writes all the unix output (echo, etc) of a script to that log file. To me the log_handler is a black box.
The log_handler is called through another script called "run_application"
(e.g. run_application somescript1 2>&1 > /dev/null )

RUN_APPLICATION script is just this:

APPLICATION=$@
LOGNAME=`basename $APPLICATION`

if [ -n "$APPLICATION" ]
then
$APPLICATION 2>&1 | /bin/log_handler $LOGNAME &
fi

Now my question is. Is it log_handler thats taking the script and logging it or is it being done through redirection and piping?? And if so how does it work? What does the 2>&1 do?

The second part would be to mimic this in java but i guess thats another thread. :slight_smile:

Thanks all for the help.

Simply ask google about "2>&1" and you're done.

PS: you aren't doing homework, are you?

Umm... sorry i graduated so I dont get any homework. I did type it into "unix 2>&1" but google eats the > and &. And also the google answer won't be specific to my question.

You just assumed that I am a student. Infact I am recently hired Business Analyst working in the IT department. The guy who is supposed to start coding the log handler in java will start in a couple of weeks. So I thought since I have time on my hands, I will help him out and try to understand how this thing works in c++ and maybe offer some real input.

And fabtagon, I sincerely hope that if you had a question regarding Free Cash Flow, you wouldnt get the same response you gave me.

p.s. As far as doing my work is concerned (which is more to do with investigation than coding hence the business degree), I did find out one thing. Fabtagon you have a special psychic ability to find out which questions is a homework question and which is a proper real life question. Now can you tell me where to find that shirt I lost?

fluke_perf: these forums have a serious homework problem, don't take it personally.

2>&1 is a redirection, yes; it directs standard error to the same place as standard output.

Without knowing what log_handler is doing, strictly speaking, it's not really possible to answer your question. The script runs APPLICATION and feeds its output and error streams to log_handler, so I suppose we can infer that if any actual logging to files is taking place, that one is taking care of that part.

For what it's worth, "$@" should always have double quotes around it.

The shirt is in the second drawer from the right; if you're lucky, you'll find an Intro to Unix Shell Scripting book there, too.