execution of shell commands in Perl Scripts

[email protected] (neelay thaker) Thu, 8 Sep 2005 14:42:50 -0700
Newsgroups perl.scripts
Message-ID <[email protected]>
------=_Part_634_1784859.1126215770811
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi,
I'm trying to use the output of a grep command in a shell script.
If I do-
$cmd =3D "grep 'abc' ./*";
$status =3D system $cmd;
Then $status always turns out to be 0, even if I use invalid arguments with=
=20
grep.
If the result of grep is not empty, I want to perform some action and if it=
=20
is empty, I want to do something else.
How can I get the output of grep into a string variable in the Perl script?
Any help will be highly appreciated.
Thanks.

Neelay.

------=_Part_634_1784859.1126215770811
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi,<br>
I'm trying to use the output of a grep command in a shell script.<br>
If I do-<br>
$cmd =3D &quot;grep 'abc' ./*&quot;;<br>
$status =3D system $cmd;<br>
Then $status always turns out to be 0, even if I use invalid arguments with=
 grep.<br>
If the result of grep is not empty, I want to perform some action and if it=
 is empty, I want to do something else.<br>
How can I get the output of grep into a string variable in the Perl script?=
<br>
Any help will be highly appreciated.<br>
Thanks.<br>
<br>
Neelay.<br>

------=_Part_634_1784859.1126215770811--