Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: unix question: KSH pipes

RE: unix question: KSH pipes

From: Steve Adams <steve.adams_at_ixora.com.au>
Date: Sat, 10 Jun 2000 09:57:19 +1000
Message-Id: <10523.108498@fatcity.com>


Hi Chuck,

The brackets mean to execute the contained list of commands in a sub-shell. That is, the shell forks, and executes the list in the child shell process. In every other respect it is just like a simple list. If you just need to group the commands (or pipelines), but don't actually need them to be executed in a sub-shell, then you should use braces instead to avoid the extra fork() call. While it is true that the remaining standard input of the list is available to subsequent commands in the list if it has only been partially read by the prior commands, the point here is that head(1) should consume its entire standard input before exiting.

Regards,
Steve Adams

http://www.ixora.com.au/
http://www.oreilly.com/catalog/orinternals/
http://www.christianity.net.au/



-----Original Message-----
From: Chuck Hamilton [SMTP:chuck_hamilton_at_yahoo.com] Sent: Saturday, June 10, 2000 2:37 AM To: Steve Adams; 'ORACLE-L_at_fatcity.com' Subject: RE: unix question: KSH pipes

 Why shouldn't it work? I thought that when commands are enclosed in ()'s they're supposed to be treated as a single command, with stdin of all the enclosed commands redirected from the same stream - the output of the previous command. What appears to be happening in my case is that the tail command doesn't pick up anything from the i/o buffer that's already been read by the head command. If the input stream is large enough, it works. When it's small (and contained in one buffer) it doesn't.

For the mean time I've changed it to...

X=`sar -w` ; echo "$X" | head -n 4; echo "$X" | tail

Steve Adams wrote:

Hi Chuck,

The two that work shouldn't. I suggest you split the output to a temporary file using tee, and use that file as the input to the tail command.

Regards,
Steve Adams

http://www.ixora.com.au/
http://www.oreilly.com/catalog/orinternals/
http://www.christianity.net.au/


-----Original Message-----

From: Chuck Hamilton [SMTP:chuck_hamilton_at_yahoo.com] Sent: Friday, June 09, 2000 3:03 AM
To: Multiple recipients of list ORACLE-L Subject: unix question: KSH pipes

I have three SGI servers running the exact same version of IRIX (6.5.5 64 bit). I have a pipeline that works fine on two of them but not on the third. Here's the pipeline...

sar -w | (head -n 4 ; tail)

It prints the first 4 lines followed by the last 10 lines of the sar output on two machines. On the third it just prints the first 4 lines. Does anyone have any idea why? Is there an environment variable or set command I need to execute to make it work as it does on the other 2 machines?



Do You Yahoo!?
Yahoo! Photos -- now, 100 FREE prints! << File: ATT00067.htm >>
Received on Fri Jun 09 2000 - 18:57:19 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US