Regards: grep: writing output: Broken pipe

Regards: grep: writing output: Broken pipe

am 23.11.2005 08:59:51 von uthayam

------=_Part_4768_15311172.1132732791985
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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=3DDBI->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=3D0;}{if(\$1~/$uid/){print
'\$1';flag=3D1;}else {if(flag==1){exit;}}}'|");
while() {
print $_."\n";
}


I kindly request you to overcome this issue.

Thansk and Regards
uthayakumar.p

------=_Part_4768_15311172.1132732791985--

RE: Regards: grep: writing output: Broken pipe

am 23.11.2005 17:06:55 von Will.Rutherdale

------_=_NextPart_001_01C5F047.EC826B64
Content-Type: text/plain

This is a user group of other people like yourself who use DBI. It is not a
support line. Please bear that in mind.

The first thing I would look at is your open() statement. There are lots of
things wrong with it.
a) determine the uid separately and store it in a string, before the open()
call.
b) don't use awk; use perl. Perl is more powerful than awk for string
processing.
c) don't grep plain text out of .gz files.

Perhaps you need to work on an introductory Perl book before delving into
DBI.

-Will


-----Original Message-----
From: Uthayakumar Paulraj [mailto:uthayam@gmail.com]
Sent: Wednesday 23 November 2005 03:00
To: dbi-users@perl.org
Subject: Regards: grep: writing output: Broken pipe


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() {
print $_."\n";
}


I kindly request you to overcome this issue.

Thansk and Regards
uthayakumar.p


- - - - - - - Appended by Scientific-Atlanta, Inc. - - - - - - -
This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.


------_=_NextPart_001_01C5F047.EC826B64--

Re: Regards: grep: writing output: Broken pipe

am 23.11.2005 22:12:57 von Tim.Bunce

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() {
> 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.

Re: Regards: grep: writing output: Broken pipe

am 28.11.2005 12:12:16 von wieland

Hello Uthayakumar,

I guess the oracle client libraries change the $SIG{CHLD} handler.

Wednesday, November 23, 2005, 8:59:51 AM, you wrote:
UP> I am using DBI module in my perl script. And also i am using the grep
UP> utility along with awk. This utility works fine when we are not initial=
ize
UP> the DB connection. If we initialize the DBI connection it throws the er=
ror
UP> "grep: writing output: Broken pipe"

$dbh=3DDBI->>connect("DBI:mysql:dbname","dbuser","dbpwd"); ### if we comment
UP> this line, works fine; uncomment this line, gives error "grep: writing
UP> output: Broken pipe"

UP> open(FH,"grep -Z '' *.gz | awk 'BEGIN {flag=3D0;}{if(\$1~/$uid/){print
UP> '\$1';flag=3D1;}else {if(flag==1){exit;}}}'|");
UP> while() {
UP> print $_."\n";
UP> }

cu
Wieland Pusch mailto:wieland@wielandpusch.de

Re: Regards: grep: writing output: Broken pipe

am 28.11.2005 15:14:29 von Tim.Bunce

On Mon, Nov 28, 2005 at 12:12:16PM +0100, Wieland Pusch wrote:
> Hello Uthayakumar,
>
> I guess the oracle client libraries change the $SIG{CHLD} handler.

While the oracle client libraries do do that, the mysql client librarary
(being used here) doesn't - as far as I know.

Tim.

> Wednesday, November 23, 2005, 8:59:51 AM, you wrote:
> UP> I am using DBI module in my perl script. And also i am using the grep
> UP> utility along with awk. This utility works fine when we are not initialize
> UP> the DB connection. If we initialize the DBI connection it throws the error
> UP> "grep: writing output: Broken pipe"
>
> $dbh=DBI->>connect("DBI:mysql:dbname","dbuser","dbpwd"); ### if we comment
> UP> this line, works fine; uncomment this line, gives error "grep: writing
> UP> output: Broken pipe"
>
> UP> open(FH,"grep -Z '' *.gz | awk 'BEGIN {flag=0;}{if(\$1~/$uid/){print
> UP> '\$1';flag=1;}else {if(flag==1){exit;}}}'|");
> UP> while() {
> UP> print $_."\n";
> UP> }
>
> cu
> Wieland Pusch mailto:wieland@wielandpusch.de
>