The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
piping from C to python in UNIX Dreams in Blue High Level Programming 0 05-04-2008 05:02 AM
Unix redirection to '&-' DILEEP410 UNIX for Dummies Questions & Answers 6 08-31-2007 05:07 AM
Piping in UNIX simo007 UNIX for Dummies Questions & Answers 3 05-22-2007 11:40 PM
Piping and redirection implementation mobile01 High Level Programming 7 12-20-2006 07:52 PM
Redirection or piping error message mariner Shell Programming and Scripting 2 05-10-2005 12:04 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-29-2008
Registered User
 

Join Date: Mar 2008
Posts: 4
Smile 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.

Thanks all for the help.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-29-2008
Registered User
 

Join Date: Apr 2008
Location: European Union/Germany
Posts: 183
Simply ask google about "2>&1" and you're done.

PS: you aren't doing homework, are you?
Reply With Quote
  #3 (permalink)  
Old 04-30-2008
Registered User
 

Join Date: Mar 2008
Posts: 4
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?

Last edited by fluke_perf; 04-30-2008 at 06:37 AM.
Reply With Quote
  #4 (permalink)  
Old 04-30-2008
era era is online now
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,094
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.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0