Perl integration with PHP

  • vonedaddy
  • Novice
  • Novice
  • vonedaddy
  • Posts: 18
  • Loc: Philadelphia

Post 3+ Months Ago

Please bare with me while I try to explain this... I am new to perl and programming in general.

So I work for a DNS team and we currently have what we call a DNS automation page. This is basically a HTML page that passes some parameters to a PHP script that adds or deletes records. It accepts the following input (username, password, action (add/delete), IP addresses, and FQDNs).

We had a need for automated zone additions as well. I wrote a perl script that will allow for automated zone additions. What I would like to do now is have my perl script send parameters to the php script and place the returned output in an array.

So basically I would like to send parameters to the PHP from my perl script and have the PHP script output back to the perl script for further manipulation.

I hope I am explaining this correctly, please excuse me if I am using the wrong terminology.
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

I suppose that would depend largely on what your return would look like, but getting at the page and pulling down the resulting content is easy enough. There are few different ways to go about it, but I've always used WWW::Mechanize from CPAN for my automation, so you'll see no different here:

Assuming a very simple to parse result list:
Code: [ Select ]

echo "Apple<br/>";
echo "Orange<br/>";
echo "Lemon<br/>";
echo "Banana<br/>";
echo "Grapefruit<br/>";
echo $_REQUEST['param1']."<br/>";
echo $_REQUEST['param2']."<br/>";

  1. <?php
  2. echo "Apple<br/>";
  3. echo "Orange<br/>";
  4. echo "Lemon<br/>";
  5. echo "Banana<br/>";
  6. echo "Grapefruit<br/>";
  7. echo $_REQUEST['param1']."<br/>";
  8. echo $_REQUEST['param2']."<br/>";
  9. ?>

And the perl script:
Code: [ Select ]

use strict;
use warnings;

use WWW::Mechanize;

my $mech = WWW::Mechanize->new();
$mech->agent_alias( 'Windows Mozilla' );

my $pageContent = $mech->content;

print $pageContent;
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use WWW::Mechanize;
  5. my $mech = WWW::Mechanize->new();
  6. $mech->agent_alias( 'Windows Mozilla' );
  7. $mech->get("");
  8. my $pageContent = $mech->content;
  9. print $pageContent;

Note that your page content WILL include HTML markup, so adjust your php script or modify your content var as needed.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 30 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.