Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have lots of Drupal powered website. Each of the website has Multiping module to pinging ping server.

Is there any way of send pinging through command-line?

I hope I can build dedicated server for pinging.

share|improve this question
2  
A "ping" in Drupal language is just a small http request with information about what node is being referenced and from where. You can replicate this action on the command line or in a script. I recommend curl to make the requests. –  Caleb Jul 29 '11 at 7:56
    
@Caleb: could have been an answer. –  Mat Mar 10 '12 at 17:52
    
@Mat: It probably should be, but without actually putting together a request that passes the right parameters to make it the expected ping format I didn't feel like it actually answered the question. –  Caleb Mar 10 '12 at 22:05
add comment

1 Answer 1

As Caleb notes, cURL is usually the weapon of choice for command-line HTTP. The tricky part - as Caleb again notes - is putting the request together, especially for XML-RPC, where the server is likely looking for a well-formed input.

But if you poke around at the source for Multipin, you see that it's not just a simple HTTP request (thought it does fall back to that) - and it changes based on what services the target service has enabled -- and, in the case of weblogUpdates -- special-cases what is sent:

// Ping! Check service method
if (!empty($pingservice->method)) {
  if ($pingservice->method == 'weblogUpdates.ping') {
    $result = xmlrpc($pingservice->url, $pingservice->method, $name, $base_url);
  }
  else {
    $result = xmlrpc($pingservice->url, $pingservice->method, $name, $base_url, $rss_url);
  }
}
else {
  $pingurl = strtr($pingservice->url, array(
    '%name' => urlencode($name),
    '%url' => urlencode($base_url .'/'),
    '%rss' => urlencode($rss_url),
  ));
  $result = drupal_http_request($pingurl);

And a few lines above, it's clever about deciding what rss URL to send, based on taxonomy, etc.

So I'd suggestion one of two approaches.

  1. If you just want to get something going, simulate the drupal_http_request by sending something like this:

    $ curl <target-pingservice-url> -d 'name=<your site name>' -d url=<your-url> -d rss=/rss.xml
    
  2. Alternatively: if want all the behavior of MultiPing, you could extract that _multiping_doping function and run it from the command line directly by PHP.

    The workhorse function you'll need is Drupal's xmlrpc: http://api.drupal.org/api/drupal/includes%21common.inc/function/xmlrpc/7

Good luck!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.