From r.buckland at qut.edu.au Thu Aug 5 21:28:57 1999 From: r.buckland at qut.edu.au (Ramon Buckland) Date: Wed Aug 4 23:59:05 2004 Subject: [BNE-PM] Socket Error Anyone help with this one ? Message-ID: <4.2.0.58.19990806105952.009e75f0@pop.qut.edu.au> Anyone able to help with this .. I am unsure if its Socket.pm that the grief or some other section. -----------8<-----------8< #!/usr/bin/perl use Net::Ping; my $host = 'localhost'; my $p = Net::Ping->new(); if (!$p->ping($host)) { print "host is alive\n"; } $p->close(); -----------8<-----------8< $perl pingtest.pl Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be 16 at /usr/lib/perl5/i686-linux/5.00405/Socket.pm line 275. ??? I tried reinstalling Perl (it installed without error) (because Socket.Pm comes in that Version: 5.004_05 : Errors Version: 5.005_02 : Errors Any ideas ? Ramon Buckland, IT Systems Administrator, Ph: 07 3864 1289 Fx: 07 3864 1823 Queensland University of Technology, Facilities Support Services Email: r.buckland@qut.edu.au http: www.fss.qut.edu.au "If you don't want problems, don't use computers" - author unkown From andrew at intervations.com.au Thu Aug 5 21:23:02 1999 From: andrew at intervations.com.au (Andrew Wild) Date: Wed Aug 4 23:59:05 2004 Subject: [BNE-PM] Socket Error Anyone help with this one ? Message-ID: <199908060315.XAA09172@happyfunball.pm.org> I tried it out under Perl 5.005_03 and got the same error... It appears to have something to do with the ping defaulting to udp. If you force it to use icmp as the protocol, it appears to work.... I wrote a quick version of it specifying icmp as the protocol and giving it a timeout value and it appeared to work: #!/usr/local/bin/perl use Net::Ping; $host = 'localhost'; $p = Net::Ping->new('icmp',1); print $p->ping($host) ? "Alive" : "Not alive"; $p->close(); Cheers, Andrew. From tim at diggy.com.au Thu Aug 5 22:36:40 1999 From: tim at diggy.com.au (Diggy Tim) Date: Wed Aug 4 23:59:05 2004 Subject: [BNE-PM] Socket Error Anyone help with this one ? References: <199908060315.XAA09172@happyfunball.pm.org> Message-ID: <006e01bedfbc$e8b3dd60$1200a8c0@tim> >I wrote a quick version of it specifying icmp as the protocol and giving it a timeout value and it appeared to work: Be aware that icmp ping requires root privileges under Solaris and therfore possibly other unix's... Cheers, Tim From apollock at bit.net.au Thu Aug 5 22:56:02 1999 From: apollock at bit.net.au (Andrew Pollock) Date: Wed Aug 4 23:59:05 2004 Subject: [BNE-PM] Socket Error Anyone help with this one ? In-Reply-To: <4.2.0.58.19990806105952.009e75f0@pop.qut.edu.au> Message-ID: <005f01bedfbf$999774a0$575e12cb@minotaur.bit.net.au> > -----Original Message----- > From: owner-brisbane-pm-list@happyfunball.pm.org > [mailto:owner-brisbane-pm-list@happyfunball.pm.org]On Behalf Of Ramon > Buckland > Sent: Friday, 6 August 1999 12:29 > To: brisbane-pm-list@happyfunball.pm.org > Subject: [BNE-PM] Socket Error Anyone help with this one ? > > > Anyone able to help with this .. I am unsure if its > Socket.pm that the grief or some other section. > > -----------8<-----------8< > #!/usr/bin/perl > > use Net::Ping; > my $host = 'localhost'; > > my $p = Net::Ping->new(); > > if (!$p->ping($host)) { > > print "host is alive\n"; > > } > > $p->close(); > -----------8<-----------8< > > $perl pingtest.pl > Bad arg length for Socket::unpack_sockaddr_in, length is 0, > should be 16 at > /usr/lib/perl5/i686-linux/5.00405/Socket.pm line 275. > > ??? > > I tried reinstalling Perl (it installed without error) (because Socket.Pm > comes in that > Version: 5.004_05 : Errors > Version: 5.005_02 : Errors > > > Any ideas ? Linux boxen? I've seen it before. On one box it works, on another it doesn't. I ended up getting the shits and writing a shell script instead... Andrew From G.Fletcher at mailbox.gu.edu.au Sun Aug 8 11:00:54 1999 From: G.Fletcher at mailbox.gu.edu.au (Gordon Fletcher) Date: Wed Aug 4 23:59:05 2004 Subject: [BNE-PM] This one bounced. Message-ID: Date: Fri, 06 Aug 1999 16:53:57 +1000 From: Ramon Buckland That's interesting .. as we are actulally testing for the ftp server to be up here is what I modified it to ############################################################ sub ping_test { my $host = shift; my $command = "ping -c 2 " . $host; return (`$command` =~ /2 packets received/); # PING 131.181.22.1 (131.181.22.1): 56 data bytes # # --- 131.181.22.1 ping statistics --- # 2 packets transmitted, 2 packets received, 0% packet loss } ############################################################ But yeah .. that doesn't guarantee the ftp server is up though. - and code portability - NIL At 04:17 6/08/99 +1000, you wrote: >If you are trying to see if a web or ftp server is up you could do some >thing like this... > >#!/usr/bin/perl >use IO::Socket; > >$host = $ARGV[0] || "localhost"; > >#is there a webserver on $host?? >my ($newsock) = new IO::Socket::INET( > PeerAddr => "$host", > PeerPort => "80", > Proto => "tcp", > ); > >if($newsock) >{ > shutdown $newsock, 2; > print "$host is alive.\n"; >}else >{ > print "$host is dead.\n"; >} > >0; Ramon Buckland, IT Systems Administrator, Ph: 07 3864 1289 Fx: 07 3864 1823 Queensland University of Technology, Facilities Support Services Email: r.buckland@qut.edu.au http: www.fss.qut.edu.au "If you don't want problems, don't use computers" - author unkown