Re: May I know the perl version of following shellscript

2003-09-22 Thread John W. Krahn
Saifuddin Bohra/Hss wrote:
> 
> Hi,

Hello,

>   I am new to Perl. I have a follpwing shell script
> 
> if [ -n "`netstat -na|grep LISTEN |grep 1099`" ];
> then
> exit 0
> else
> exit 1
> fi
> 
> I need the perl script for the same job.
> and how to use this in another perl program
> Any pointer ??


#!/usr/bin/perl
use warnings;
use strict;

open PIPE, 'netstat -na |' or die "Cannot open pipe from netstat: $!";

while (  ) {
exit 0 if /LISTEN/ and /1099/;
}
exit 1;

__END__



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: May I know the perl version of following shellscript

2003-09-22 Thread Jeff Westman

--- Saifuddin_Bohra/[EMAIL PROTECTED] wrote:
>
> Hi,
>   I am new to Perl. I have a follpwing shell script
> 
> if [ -n "`netstat -na|grep LISTEN |grep 1099`" ];
> then
> exit 0
> else
> exit 1
> fi
> 
> I need the perl script for the same job.
> and how to use this in another perl program
> Any pointer ??
> 
> saifuddin

This should work .

#!/bin/perl
use warnings;
use strict; 

if ( length(qx(netstat -na|grep LISTEN |grep 1099)) > 0 ) {
exit(0);
}
else {
exit(1);
}

(There are ways to shorten this, but this is the basic code I think you are
looking for)


-Jeff


__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



May I know the perl version of following shellscript

2003-09-22 Thread Saifuddin_Bohra/HSS




Hi,
  I am new to Perl. I have a follpwing shell script

if [ -n "`netstat -na|grep LISTEN |grep 1099`" ];
then
exit 0
else
exit 1
fi

I need the perl script for the same job.
and how to use this in another perl program
Any pointer ??

saifuddin


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]