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'm really new to Unix and I can't figure out what this command does. From what I understand, it sends an HTTP POST request to a website. I don't know exactly what each line is supposed to do. Can someone kindly explain to me the function of each line?

Here's the command:

curl http://www.example.com/xmlrpc.php -d 
    '
    pingback.ping
    http://destination.site.com/

    http://www.example.com/
    '
share|improve this question
    
What it does entirely depends on xmlrpc.php. You are sending data as part of the POST request, but it's up to xmlrpc.php to interpret that data as grounds for action. –  Chris Down Jan 27 at 3:28
    
@ChrisDown Okay, I see. What exactly do the ' ' do? I'm guessing they're equivalent to brackets {} in programming? –  Sedulous Jan 27 at 3:36

1 Answer 1

up vote 0 down vote accepted

This is most likely a Wordpress website. The xmlrpc.php script is a PHP script that provides remote procedure calls (hence the rpc in the name) which allow you to run things on the server. These are just like methods in a Class.

Examples

<?xml version="1.0"?>
<methodCall>
   <methodName>pingback.ping</methodName>
   <params>
      <param>
        <value><string>http://.source./</string></value>
      </param>
      <param>
        <value><string>http://.target./</string></value>
      </param>
   </params>
</methodCall>

When you call the URL in your example, you're calling the pingback.ping method and providing the URLs after the call as arguments to this method. The 1st URL is the source URL of the pingback while the 2nd is the target URL.

curl's -d switch

From curl's man page:

-d/--data <data>
      (HTTP) Sends the specified data in a POST request to the HTTP server, 
      in a way that can emulate as if a user has filled in a HTML form and 
      pressed the submit  button.  Note  that  the  data  is  sent exactly 
      as specified with no extra processing (with all newlines cut off).  
      The data is expected to be "url-encoded". This will cause curl to pass 
      the data to the server using the content-type 
      application/x-www-form-urlencoded. Compare to -F/--form. If this 
      option is used more than once on the same command line, the data 
      pieces specified will be merged together with a separating &-letter. 
      Thus, using ’-d name=daniel -d skill=lousy’ would generate a post 
      chunk that looks like ’name=daniel&skill=lousy’.

      If  you  start  the  data  with  the  letter @, the rest should be a 
      file name to read the data from, or - if you want curl to read the 
      data from stdin.  The contents of the file must already be 
      url-encoded. Multiple files can also be specified. Posting data from a 
      file named ’foobar’ would thus be done with --data @foobar".

      To post data purely binary, you should instead use the --data-binary 
      option.

      -d/--data is the same as --data-ascii.

      If this option is used several times, the ones following the first 
      will append data.
share|improve this answer
    
Thank you, exactly what I was looking for! –  Sedulous Jan 27 at 4:32
    
@Sedulous - glad to of helped. Thanks for the Q. –  slm Jan 27 at 4:34

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.