On Wed, Nov 23, 2005 at 01:29:51PM +0530, Uthayakumar Paulraj wrote:
> Dear Sir/Madam,
> 
> I am using DBI module in my perl script. And also i am using the grep
> utility along with awk. This utility works fine when we are not initialize
> the DB connection. If we initialize the DBI connection it throws the error
> "grep: writing output: Broken pipe"
> 
> $dbh=DBI->connect("DBI:mysql:dbname","dbuser","dbpwd"); ### if we comment
> this line, works fine; uncomment this line, gives error "grep: writing
> output: Broken pipe"
> 
> open(FH,"grep -Z '' *.gz | awk 'BEGIN {flag=0;}{if(\$1~/$uid/){print
> '\$1';flag=1;}else {if(flag==1){exit;}}}'|");
> while(<FH>) {
>  print $_."\n";
> }
> 
> I kindly request you to overcome this issue.

The error from grep will be due to awk exiting before it has processed
all the data from grep. That's probably due to the exit in the awk script.

It's not clear why using DBI should affect the behaviour.
But you've not included the whole script so I can't help more.
I suggest you rewrite the awk script to not use exit, or
rewrite the script to not need awk at all.

Tim.

Reply via email to