Re: Simple Script That Runs Under Perl 5.8 but not under Perl 5.10

2010-11-23 Thread John W. Krahn

Greg Grant wrote:


The following script runs on 5.8 but does not run on 5.10.  I
distilled out a short program with the heart of the bug. The output of
this script could be achieved easily without recursion but my real
sort routine does need to be recursive, but I removed most of the
code. Ignore the fact that this doesn't achieve something useful as
is, the point is it runs on 5.8 and not on 5.10.

use strict;


Should also have:

use warnings;



my %SAM;
$SAM{chr2LHet} = 1;
$SAM{chr2RHet} = 1;
$SAM{chr3LHet} = 1;
$SAM{chr3RHet} = 1;


That is usually written as:

my %SAM = (
chr2LHet => 1,
chr2RHet => 1,
chr3LHet => 1,
chr3RHet => 1,
);



foreach my $chr (sort cmpChrs keys %SAM) {
 print "CHR=$chr\n";
}
sub cmpChrs () {


Why are you using a prototype?  You should only use prototypes if you 
are trying to imitate one of perl's built-in functions.




 if($a =~ /chr(\d+)/) {


Since you are removing that string anyway, why not just remove it here?



 my $numa = $1;
 if($b =~ /chr(\d+)/) {


ditto.


 my $numb = $1;
 if($numa<  $numb) { return 1; }
 else {
 $a =~ s/chr\d+//;
 $b =~ s/chr\d+//;
 my %temp;
 $temp{$a}=1;
 $temp{$b}=1;
 foreach my $key (sort cmpChrs keys %temp) {
 if($key eq $a) { return 1; }
 else { return -1; }


That is usually written as:

   return $key eq $a ? 1 : -1;



 }


Why do you need a hash and a foreach loop to compare the TWO values in 
$a and $b?




 }
 } else { return 1; }
 }
 return 1;
}


I don't see anywhere in that subroutine where you return 0 which 
indicates that the two values are equal.  It appears that the values are 
only ever less than or greater than each other?




---
On 5.8 it does not crash and outputs the following:
CHR=LHet
CHR=RHet
CHR=LHet
CHR=RHet

On 5.10 it crashes with the following message:

Can't undef active subroutine at test.pl line 29.
Attempt to free unreferenced scalar: SV 0x1124fa0, Perl interpreter:
0x10f7010 at test.pl line 29.
Attempt to free unreferenced scalar: SV 0x1124fa0, Perl interpreter:
0x10f7010 at test.pl line 29.


Perhaps you need to declare the subroutine before you define it:

sub cmpChrs;

sub cmpChrs {

# define sub here
}


---

I had to do the following to fix it:

use strict;
my %SAM;
$SAM{chr2LHet} = 1;
$SAM{chr2RHet} = 1;
$SAM{chr3LHet} = 1;
$SAM{chr3RHet} = 1;
foreach my $chr (sort {cmpChrs($a,$b)} keys %SAM) {


1.  Your prototype says that cmpChrs takes zero arguments.

2.  Your use of parentheses suggests that you want to call the
subroutine and pass its return value to sort but that is not how
sort works.



 print "CHR=$chr\n";
}
sub cmpChrs () {





John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Monitoring ssh connectivity to a server using perl !

2010-11-23 Thread shawn wilson
I like net::ping. But what's the point of reinventing the wheel? There's
dozens of network monitoring suites that'll do this for you - nagios for one
should suite the purpose well enough.

Also, nmap should have a module to allow you to audit ssh. With any luck,
you might be able to access that from perl.
On Nov 23, 2010 9:55 PM, "Peter Scott"  wrote:
> On Tue, 23 Nov 2010 21:59:19 +0530, Amit Saxena wrote:
>
>> Hi all,
>>
>> What's the best way to monitor ssh connectivity, and not just ssh port
>> availability, to a server using perl assuming following constraints ?
>>
>> I tried for Net::SSH but public private key is not allowed.
>>
>> I tried for Net::SSH::Perl etc but these are not built in perl
>> distribution (active perl on windows or part of perl distribution of
>> linux / solaris).
>>
>> Can we do it via "IO::Socket::INET" ?
>
> If it's enough to check that something's listening to port 22:
>
> perl -MNet::Ping -le '$p=Net::Ping->new; $p->port_number(22); $p->ping
> (localhost) or warn "SSH down"'
>
> --
> Peter Scott
> http://www.perlmedic.com/ http://www.perldebugged.com/
> http://www.informit.com/store/product.aspx?isbn=0137001274
> http://www.oreillyschool.com/courses/perl3/
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>


Re: Check if file is open in unix

2010-11-23 Thread Shlomi Fish
Hi Gopal,

On Tuesday 23 November 2010 14:01:20 Gopal Karunakar wrote:
> Hi All,
> 
> I want to check whether a particular file (a simple text file) is open
> in the UNIX environment. i.e. I want to make sure that its not getting
> written into by some other process before my Perl process open it. So that
> it will always get a complete file. Is there some way of making sure of
> this??
> 

See this thread:

http://www.nntp.perl.org/group/perl.beginners/2010/11/msg114616.html

Quoting my email:

{{{
On Tuesday 02 November 2010 20:49:04 perl_haxor 123 wrote:
> Hi All,
> 
>   I have a directory in which i have multiple files, i have to read
> each one of them and parse the data..but there could be some files
> which are in use by some other program, how can i find which files are in
> use by other program in perl?...any suggestions would be really
> helpful.
> 

I don't know about Windows, but on UNIX you can use lsof:

http://en.wikipedia.org/wiki/Lsof

This page says that http://en.wikipedia.org/wiki/Process_Explorer is the 
Windows equivalent.

However, you should rethink your strategy. If you want well-behaving processes 
not to step on each others' toes you can use file locking for that.
}}

Regards,

Shlomi Fish

-- 
-
Shlomi Fish

 She's a hot chick. But she smokes.
 She can smoke as long as she's smokin'.

Please reply to list if it's a mailing list post.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl web apps

2010-11-23 Thread Shlomi Fish
On Monday 22 November 2010 18:41:50 shawn wilson wrote:
> On Mon, Nov 22, 2010 at 10:59 AM, Robert Wohlfarth 
wrote:
> > On Mon, Nov 22, 2010 at 9:02 AM, shawn wilson  wrote:
> > > any of y'all write web apps in perl? what do you use? i'm using
> > > html::template but i was thinking of going back to straight cgi.pm or
> > > having
> > > my perl send back json for the page to render (but i'm not that
> > > familiar with js). thoughts?
> > 
> > Check out Catalyst (http://www.catalystframework.org/). It handles the
> > drudgery without forcing you into one way of doing things.
> 
> so, pretty much, catalyst seperates out your events (queries, layout, base
> code) and mason gives a nice interface between html and perl?
> 

Yes.

> any room for cgi::ajax in this or is that missing the point or replicating
> functionality of mason?
> 

Don't use CGI::Ajax. It is a minimalistic module for use primarily with CGI.pm 
and you probably should not be using CGI.pm. Catalyst has mechanisms to handle 
AJAX (as other people noted).

> are there any good manuals or books that might help me here? (i like
> examples more than theory)
> 

First of all see:

http://perl-begin.org/uses/web/

If you wish to learn about Catalyst, then there are plenty of resourrces 
mentioned on the Catalyst site - http://www.catalystframework.org/ - and the 
linked wiki and CPAN pages. There's a Catalyst-Manual distro on CPAN with a 
manual and a tutorial:

http://search.cpan.org/dist/Catalyst-Manual/

In addition to Catalyst, you may wish to check out Dancer:

http://perl-begin.org/uses/web/#dancer

Regarding HTML-Template - I would strongly recommend against it. I don't like 
it and it has gone unmaintained for some time (though there are some active 
clones on CPAN). I much prefer Template-Toolkit , and there are other 
alternatives like ClearSilver or HTML-Mason. Also see:

http://perl-begin.org/uses/text-generation/

Regards,

Shlomi Fish

-- 
-
Shlomi Fish

 She's a hot chick. But she smokes.
 She can smoke as long as she's smokin'.

Please reply to list if it's a mailing list post.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Installation of Net::MySQL

2010-11-23 Thread Shlomi Fish
Hi BlackSwan,

On Monday 22 November 2010 03:10:50 blackswa...@yahoo.com wrote:
> My installation of RedHat Linux server 5.3 came with PERL 5.8.  I
> updated my version of PERL to 5.12, and my copy of PERL resides at /
> root/localperl/bin/perl
> 
> I've attempted to install DBD, DBI and Net::MySQL and all failed.  It
> is possible that the reason why the installs are failing is common to
> all three, but I do not know that as a fact, so I am asking you to
> look over and respond as to what I may be doing wrong in the
> installation of Net::MySQL.
> 
> I'm following the instructions that come with Net::MySQL - Pure Perl
> MySQL network protocol interface.  Any attempts to use perl without
> the full path to /root fails because the initial installation was
> written over by an incorrect installation of version 5.12 on /usr/bin/
> perl
> 
> 
> r...@localhost localperl# /root/localperl/bin/perl -v
> This is perl 5, version 12, subversion 2 (v5.12.2) built for x86_64-
> linux
> 
> -
> 
> r...@localhost bin# pwd
> /root/localperl/bin
> r...@localhost bin# cd ..
> r...@localhost localperl# ls
> bin  lib  man
> r...@localhost localperl# ls
> bin  lib  man  Net-MySQL-0.09
> r...@localhost localperl# cd Net-MySQL-0.09/
> r...@localhost Net-MySQL-0.09# ls
> Changes  Makefile.PL  MANIFEST  META.yml  MySQL.pm  README  script  t
> r...@localhost Net-MySQL-0.09# root/localperl/bin/perl Makefile.PL
> PREFIX=/root/localperl/bin/perl/lib
> bash: root/localperl/bin/perl: No such file or directory
> r...@localhost Net-MySQL-0.09# root/localperl/bin/perl Makefile.PL
> PREFIX=/root/localperl
> bash: root/localperl/bin/perl: No such file or directory
> r...@localhost Net-MySQL-0.09# /root/localperl/bin/perl Makefile.PL
> PREFIX=/root/localperl
> Checking if your kit is complete...
> Looks good
> Writing Makefile for Net::MySQL
> r...@localhost Net-MySQL-0.09# make
> cp MySQL.pm blib/lib/Net/MySQL.pm
> Manifying blib/man3/Net::MySQL.3
> r...@localhost Net-MySQL-0.09# make test
> PERL_DL_NONLAZY=1 /root/localperl/bin/perl "-MExtUtils::Command::MM" "-
> e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
> t/0.load.t  Can't locate Digest/SHA1.pm in @INC (@INC
> contains: /root/localperl/Net-MySQL-0.09/blib/lib /root/localperl/Net-
> MySQL-0.09/blib/arch /root/localperl/lib/site_perl/5.12.2/x86_64-
> linux /root/localperl/lib/site_perl/5.12.2 /root/localperl/lib/5.12.2/
> x86_64-linux /root/localperl/lib/5.12.2 .) at /root/localperl/Net-
> MySQL-0.09/blib/lib/Net/MySQL.pm line 681.

Seems like Net-MySQL has an undeclared dependency on Digest-SHA1 so you need 
to install it first:

http://search.cpan.org/dist/Digest-SHA1/

Maybe see:

http://perl-begin.org/topics/cpan/

Regards,

Shlomi Fish

-- 
-
Shlomi Fish

 She's a hot chick. But she smokes.
 She can smoke as long as she's smokin'.

Please reply to list if it's a mailing list post.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Monitoring ssh connectivity to a server using perl !

2010-11-23 Thread Peter Scott
On Tue, 23 Nov 2010 21:59:19 +0530, Amit Saxena wrote:

> Hi all,
> 
> What's the best way to monitor ssh connectivity, and not just ssh port
> availability, to a server using perl assuming following constraints ?
> 
> I tried for Net::SSH but public private key is not allowed.
> 
> I tried for Net::SSH::Perl etc but these are not built in perl
> distribution (active perl on windows or part of perl distribution of
> linux / solaris).
> 
> Can we do it via "IO::Socket::INET" ?

If it's enough to check that something's listening to port 22:

perl -MNet::Ping -le '$p=Net::Ping->new; $p->port_number(22); $p->ping
(localhost) or warn "SSH down"'

-- 
Peter Scott
http://www.perlmedic.com/ http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274
http://www.oreillyschool.com/courses/perl3/

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: [PBML] Re: Monitoring ssh connectivity to a server using perl !

2010-11-23 Thread Amit Saxena
On Wed, Nov 24, 2010 at 1:19 AM, Joe Pepersack  wrote:

>
>
> Why not just call the ssh client and run a command on the remote host?
> I'd set up a passwordless key to a restricted account for security, but
> I'm paranoid.
>
> open LOG, '>>', '/path/to/logfile' or die "Can't open log file\n";
>
> foreach my $target ( qw[ u...@host1 u...@host2 u...@localhost ] ) {
> my $uptime = `/usr/bin/ssh -i /path/to/private_key $target uptime`;
> my $now = localtime;
>
> if ( defined($uptime) ) {
> print LOG "$now\tSSH is up on $target\n";
> }
> else {
> print LOG "$now\tSSH is down on $target\n";
>
> }
> }
>
> On 11/23/2010 11:43 AM, Amit Saxena wrote:
> >
> > On Tue, Nov 23, 2010 at 10:09 PM, shawn wilson 
> > 
> > > wrote:
> >
> > > Well, each new ssh connection should spawn a new process so you
> > could look
> > > at it from that end. More technically, you could look into netstat
> > or lsof
> > > modules.
> > > On Nov 23, 2010 11:31 AM, "Amit Saxena" 
> > > 
> > > wrote:
> > > > Hi all,
> > > >
> > > > What's the best way to monitor ssh connectivity, and not just ssh
> port
> > > > availability, to a server using perl assuming following constraints ?
> > > >
> > > > I tried for Net::SSH but public private key is not allowed.
> > > >
> > > > I tried for Net::SSH::Perl etc but these are not built in perl
> > > distribution
> > > > (active perl on windows or part of perl distribution of linux /
> > solaris).
> > > >
> > > > Can we do it via "IO::Socket::INET" ?
> > > >
> > > > Thanks & Regards,
> > > > Amit Saxena
> > >
> >
> > Thanks Shawn for the reply.
> >
> > Actually my requirement, to be specific, is as follows.
> >
> > The script will be executed in periodic fashion from a *nix server and
> the
> > script will initiate a ssh connection to itself using perl. This is to
> > confirm that the ssh service is running and there is no issue in getting
> a
> > new and authenticated ssh session when clients will connect to the server
> > via ssh externally.
> >
> > Please suggest.
> >
> > Thanks & Regards,
> > Amit Saxena
> >
> > [Non-text portions of this message have been removed]
> >
> >
>
> [Non-text portions of this message have been removed]
>
>  __._,_.___
>   Reply to 
> sender|
>  Reply
> to 
> group|
>  Reply
> via web 
> post|
>  Start
> a New 
> Topic
> Messages in this 
> topic(
> 3)
>  Recent Activity:
>
>- New 
> Members
>2
>
>  Visit Your 
> Group
>  Unsubscribing info is here:
> http://help.yahoo.com/help/us/groups/groups-32.html
>  [image: Yahoo! 
> Groups]
> Switch to: 
> Text-Only,
> Daily 
> Digest•
> Unsubscribe• 
> Terms
> of Use 
>.
>
> __,_._,___
>

Hi Joe,

I feel, I have to settle for this option in the end. However is there a way
to NOT to use public-private key with ssh and have embedded password in the
ssh command itself to have non interactive output ?

Thanks & Regards,
Amit Saxena


Simple Script That Runs Under Perl 5.8 but not under Perl 5.10

2010-11-23 Thread Greg Grant
The following script runs on 5.8 but does not run on 5.10.  I
distilled out a short program with the heart of the bug. The output of
this script could be achieved easily without recursion but my real
sort routine does need to be recursive, but I removed most of the
code. Ignore the fact that this doesn't achieve something useful as
is, the point is it runs on 5.8 and not on 5.10.

use strict;
my %SAM;
$SAM{chr2LHet} = 1;
$SAM{chr2RHet} = 1;
$SAM{chr3LHet} = 1;
$SAM{chr3RHet} = 1;
foreach my $chr (sort cmpChrs keys %SAM) {
print "CHR=$chr\n";
}
sub cmpChrs () {
if($a =~ /chr(\d+)/) {
my $numa = $1;
if($b =~ /chr(\d+)/) {
my $numb = $1;
if($numa < $numb) { return 1; }
else {
$a =~ s/chr\d+//;
$b =~ s/chr\d+//;
my %temp;
$temp{$a}=1;
$temp{$b}=1;
foreach my $key (sort cmpChrs keys %temp) {
if($key eq $a) { return 1; }
else { return -1; }
}
}
} else { return 1; }
}
return 1;
}
---
On 5.8 it does not crash and outputs the following:
CHR=LHet
CHR=RHet
CHR=LHet
CHR=RHet

On 5.10 it crashes with the following message:

Can't undef active subroutine at test.pl line 29.
Attempt to free unreferenced scalar: SV 0x1124fa0, Perl interpreter:
0x10f7010 at test.pl line 29.
Attempt to free unreferenced scalar: SV 0x1124fa0, Perl interpreter:
0x10f7010 at test.pl line 29.
---

I had to do the following to fix it:

use strict;
my %SAM;
$SAM{chr2LHet} = 1;
$SAM{chr2RHet} = 1;
$SAM{chr3LHet} = 1;
$SAM{chr3RHet} = 1;
foreach my $chr (sort {cmpChrs($a,$b)} keys %SAM) {
print "CHR=$chr\n";
}
sub cmpChrs () {
if($a =~ /chr(\d+)/) {
my $numa = $1;
if($b =~ /chr(\d+)/) {
my $numb = $1;
if($numa < $numb) { return 1; }
else {
$a =~ s/chr\d+//;
$b =~ s/chr\d+//;
my %temp;
$temp{$a}=1;
$temp{$b}=1;
foreach my $key (sort {cmpChrs($a,$b)} keys %temp) {
if($key eq $a) { return 1; }
else { return -1; }
}
}
} else { return 1; }
}
return 1;
}
---

The strangest thing is that it has no problem with the first two top
level calls of the subroutine where it does call itself recursively,
and it has no problem with the third top level call where it does not
call itself recursively. It crashes on the fourth top level call where
it also does not call itself recursively and is basically the same as
the previous time it was called. So that's very strange and
inconsistent behavior leading me to believe it is not intended. But
I'm really not an expert.

Not sure if this is a bug in 5.10 or if I was using an illegal syntax
that just wasn't enforced in 5.8.  But in any case it's curious.


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Hashes from files. Unable to access values. Please, please help.

2010-11-23 Thread addie
> Where did $var come from?
Sorry about that. That was a left over from the actual code that I
tried to pare down to be a small example. Messed that up as badly as
the copy/paste of the code made it really very ugly.

Addie


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Monitoring ssh connectivity to a server using perl !

2010-11-23 Thread C.DeRykus
On Nov 23, 8:29 am, learn.tech...@gmail.com (Amit Saxena) wrote:
> Hi all,
>
> What's the best way to monitor ssh connectivity, and not just ssh port
> availability, to a server using perl assuming following constraints ?
>
> I tried for Net::SSH but public private key is not allowed.
>
> I tried for Net::SSH::Perl etc but these are not built in perl distribution
> (active perl on windows or part of perl distribution of linux / solaris).
>
> Can we do it via "IO::Socket::INET" ?
>

You may want to consider Net::SSH2 which, although
only SSH2 is supported, is much easier to build.

I notice there's a  Win32  perl-5.12 Net::SSH2 pre-
built available from:

   http://cpan.uwinnipeg.ca/PPMPackages/12xx/

You just have to add the additional repository to your
Activestate distro as I recall before doing the ppm
install.

I've built Net::SSH2 on both Linux and Solaris in the
past too. Net::SSH::Perl is another possibity  but
quite challenging and I wouldn't recommend it unless
you've got lots of time and tenacity.

--
Charles DeRykus


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Check if file is open in unix

2010-11-23 Thread Arun G Nair
On Tue, Nov 23, 2010 at 5:31 PM, Gopal Karunakar
 wrote:
> Hi All,
>
>    I want to check whether a particular file (a simple text file) is open
> in the UNIX environment. i.e. I want to make sure that its not getting
> written into by some other process before my Perl process open it. So that
> it will always get a complete file. Is there some way of making sure of
> this??
>
> Thanks & Regards,
>
> GK.
>

http://stackoverflow.com/questions/1048592/how-to-check-if-a-file-has-been-opened-by-another-application-in-c

-- 
::: Keep Smiling :::

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Monitoring ssh connectivity to a server using perl !

2010-11-23 Thread Arun G Nair
On Tue, Nov 23, 2010 at 10:13 PM, Amit Saxena  wrote:
>
> On Tue, Nov 23, 2010 at 10:09 PM, shawn wilson  wrote:
>
> > Well, each new ssh connection should spawn a new process so you could look
> > at it from that end. More technically, you could look into netstat or lsof
> > modules.
> > On Nov 23, 2010 11:31 AM, "Amit Saxena"  wrote:
> > > Hi all,
> > >
> > > What's the best way to monitor ssh connectivity, and not just ssh port
> > > availability, to a server using perl assuming following constraints ?
> > >
> > > I tried for Net::SSH but public private key is not allowed.
> > >
> > > I tried for Net::SSH::Perl etc but these are not built in perl
> > distribution
> > > (active perl on windows or part of perl distribution of linux / solaris).
> > >
> > > Can we do it via "IO::Socket::INET" ?
> > >
> > > Thanks & Regards,
> > > Amit Saxena
> >
>
> Thanks Shawn for the reply.
>
> Actually my requirement, to be specific, is as follows.
>
> The script will be executed in periodic fashion from a *nix server and the
> script will initiate a ssh connection to itself using perl. This is to
> confirm that the ssh service is running and there is no issue in getting a
> new and authenticated ssh session when clients will connect to the server
> via ssh externally.
>
> Please suggest.
>
> Thanks & Regards,
> Amit Saxena


I don't have experience with perl SSH module(s). But I have read about
Net::SSH::Perl being slow. I don't think IO::Socket is a viable option
because you'll have to manage the encryption and nitty-gritty of SSH
itself. I guess your only options are to either go with Net::SSH::Perl
(it supports public key authentication) or to use the OS's ssh client
in system().

_agn_
--
::: Keep Smiling :::

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Monitoring ssh connectivity to a server using perl !

2010-11-23 Thread Amit Saxena
On Tue, Nov 23, 2010 at 10:09 PM, shawn wilson  wrote:

> Well, each new ssh connection should spawn a new process so you could look
> at it from that end. More technically, you could look into netstat or lsof
> modules.
> On Nov 23, 2010 11:31 AM, "Amit Saxena"  wrote:
> > Hi all,
> >
> > What's the best way to monitor ssh connectivity, and not just ssh port
> > availability, to a server using perl assuming following constraints ?
> >
> > I tried for Net::SSH but public private key is not allowed.
> >
> > I tried for Net::SSH::Perl etc but these are not built in perl
> distribution
> > (active perl on windows or part of perl distribution of linux / solaris).
> >
> > Can we do it via "IO::Socket::INET" ?
> >
> > Thanks & Regards,
> > Amit Saxena
>

Thanks Shawn for the reply.

Actually my requirement, to be specific, is as follows.

The script will be executed in periodic fashion from a *nix server and the
script will initiate a ssh connection to itself using perl. This is to
confirm that the ssh service is running and there is no issue in getting a
new and authenticated ssh session when clients will connect to the server
via ssh externally.

Please suggest.

Thanks & Regards,
Amit Saxena


Re: Monitoring ssh connectivity to a server using perl !

2010-11-23 Thread shawn wilson
Well, each new ssh connection should spawn a new process so you could look
at it from that end. More technically, you could look into netstat or lsof
modules.
On Nov 23, 2010 11:31 AM, "Amit Saxena"  wrote:
> Hi all,
>
> What's the best way to monitor ssh connectivity, and not just ssh port
> availability, to a server using perl assuming following constraints ?
>
> I tried for Net::SSH but public private key is not allowed.
>
> I tried for Net::SSH::Perl etc but these are not built in perl
distribution
> (active perl on windows or part of perl distribution of linux / solaris).
>
> Can we do it via "IO::Socket::INET" ?
>
> Thanks & Regards,
> Amit Saxena


Monitoring ssh connectivity to a server using perl !

2010-11-23 Thread Amit Saxena
Hi all,

What's the best way to monitor ssh connectivity, and not just ssh port
availability, to a server using perl assuming following constraints ?

I tried for Net::SSH but public private key is not allowed.

I tried for Net::SSH::Perl etc but these are not built in perl distribution
(active perl on windows or part of perl distribution of linux / solaris).

Can we do it via "IO::Socket::INET" ?

Thanks & Regards,
Amit Saxena


Re: Check if file is open in unix

2010-11-23 Thread Chandrashekar Bhat
This might be useful...
__CODE__

use Fcntl qw/O_WRONLY O_CREAT O_EXCL/;
open(FH, "<", $file)
or sysopen(FH, $file, O_WRONLY | O_CREAT | O_EXCL)
or die "can't create new file $file: $!";

__CODE__

Thanks,
Chandrashekar



On Tue, Nov 23, 2010 at 5:31 PM, Gopal Karunakar
wrote:

> Hi All,
>
>I want to check whether a particular file (a simple text file) is open
> in the UNIX environment. i.e. I want to make sure that its not getting
> written into by some other process before my Perl process open it. So that
> it will always get a complete file. Is there some way of making sure of
> this??
>
> Thanks & Regards,
>
> GK.
>


Check if file is open in unix

2010-11-23 Thread Gopal Karunakar
Hi All,

I want to check whether a particular file (a simple text file) is open
in the UNIX environment. i.e. I want to make sure that its not getting
written into by some other process before my Perl process open it. So that
it will always get a complete file. Is there some way of making sure of
this??

Thanks & Regards,

GK.