Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Ping code

Posted by TedH (TedH), 25 June 2008
Hi, I've finally managed to get a pinger script that works, but it only does one server. Like this:
Code:
our $endpoint = 'thefirstping';


Am I right in thinking that to do multiples I'd have to write it like this?

Code:
our $endpoint = ['thefirstping','anotherone','yetonemore'];


Though I'd check before testing it out and messing things up if it's wrong.

Cheers - Ted

Posted by KevinAD (KevinAD), 26 June 2008
Obviously if you want to ping more than one server you have to provide a list of the servers to the ping routine. But how the list is supplied or formatted depends on how you are pinging the servers. Your syntax is a little unusual in that it is a reference to an array instead of just a normal array:

@list = qw(this that theother);

Posted by TedH (TedH), 26 June 2008
Hi Kevin, maybe it's best I show the whole thing. I found the script on a site, but it's some strange language and would not let me contact the site owner.

All I know is that it works a treat and I can see the most recent posting within a few minutes on the Google Blog search.

I've tried to understand these things (I have enuf trouble with Perl - let alone xml), so if I find something that actually does the job, then I can learn and glean from it - this however exposes my complete stupidity on the subject (grin/groan).

Code:
#!/usr/bin/perl

use strict;
use warnings;
use XMLRPC::Lite;

our $endpoint = 'http://blogsearch.google.com/ping/RPC2'; ## Can this be multiple?

#### This refers to my domain and is okay
#### (parameters is XMLRPC Lite - understood) - T
my @parameters = (
   'Site name',
   'http://www.domain/',
   'http://www.domain/index.html',
   'http://www.domain/sitename.xml',
);

#### This bit raises questions unless it applies to all servers
#### I see the $endpoint usage (XMLRPC Lite requirement?) - T
my $result = XMLRPC::Lite
   -> proxy($endpoint)
   -> call('weblogUpdates.extendedPing', @parameters)
   -> result;

#### Seems to be standard thing
#### result is from above - T
print qq/$result->{message}($result->{flerror})\n/;



I assume the "our $endpoint" is used by XMLRPC Lite. It's the 'our' that throws me, I've never seen that used before. I can see what the script is doing well enough.

Your array use is good idea (tested with print and html break to see it work - twas good), so am I right with this:

Code:
@list = qw(
this
that
theother
);

foreach $item (@list) {
our $endpoint "$item\n";
}


- Ted

Posted by KevinAD (KevinAD), 26 June 2008
You could look up "our" in the perl documentation. "our" is very similar to "my", and you could probably use "my" in that code without any difference.

While I am not familair with the XMLRPC::Lite module or the XMLRPC protocol,  the solution to your question is just using a loop. It might be possible to define alist as the argument to the proxy method byut the module documentation is sparse and does not mention the options (if any) you can provide as arguments to the methods. For example, instead of a loop you could try something like this:



#!/usr/bin/perl

use strict;
use warnings;
use XMLRPC::Lite;

our @endpoint = qw(this that theother);

#### This refers to my domain and is okay
#### (parameters is XMLRPC Lite - understood) - T
my @parameters = (
   'Site name',
   'http://www.domain/',
   'http://www.domain/index.html',
   'http://www.domain/sitename.xml',
);

#### This bit raises questions unless it applies to all servers
#### I see the $endpoint usage (XMLRPC Lite requirement?) - T
my $result = XMLRPC::Lite
   -> proxy(\@endpoint)
   -> call('weblogUpdates.extendedPing', @parameters)
   -> result;

#### Seems to be standard thing
#### result is from above - T
print qq/$result->{message}($result->{flerror})\n/;  

I have no idea if it will work. You could also try just using the list instead of a reference to the list:

-> proxy(@endpoint)


If not you can just wrap the code in a loop:

#!/usr/bin/perl

use strict;
use warnings;
use XMLRPC::Lite;

our @endpoint = qw(this that theother);

#### This refers to my domain and is okay
#### (parameters is XMLRPC Lite - understood) - T
my @parameters = (
   'Site name',
   'http://www.domain/',
   'http://www.domain/index.html',
   'http://www.domain/sitename.xml',
);

for (@endpoint) {
#### This bit raises questions unless it applies to all servers
#### I see the $endpoint usage (XMLRPC Lite requirement?) - T
my $result = XMLRPC::Lite
   -> proxy($_)
   -> call('weblogUpdates.extendedPing', @parameters)
   -> result;

#### Seems to be standard thing
#### result is from above - T
print qq/$result->{message}($result->{flerror})\n/;
}

and that should work. You may have to redefine the @paramaters array for each endpoint if necessary.

Posted by TedH (TedH), 26 June 2008
Thanks Kevin, I'll look at it manyana - I've spent most of the day trying sort out a friends PC. She managed to get some really nasty malware called anti virus xp 2008  on it and it's virtually trashed her system. My head is done in big time. Watch out for this thing - it sneaks in via the Windows automatic update (which I've had turned off for years, but she didn't).

Posted by KevinAD (KevinAD), 27 June 2008
Thanks for the heads up, hopefully my AVG anti-virus will catch and stop it if I get it. I have run AVG for years and never had a single virus..... yet.

Posted by TedH (TedH), 27 June 2008
It's not a virus. It is MalWare! Walked straight thru AVG7. Maybe AVG8 is aware of it, dunno the malware would not let it install proeprly, so it couldn't run. This thing turns off firewalls and any genuine anti-virus you have. Very nasty piece of work.

Friend had 7 I went to install 8, she told about this thing and I saw it and thought at first it was a new Microsoft product.

She had okayed the update thinking it was from MS. The other way it get's in (AVG will take care of) is by a trojan dropped on when visiting some websites.

She's going to have her system reinstalled by an engineer and I'll make sure Windows update is off afterwards.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho