Does anyone know, if I can use perl and php together in postwwwacct or no? If not, does anyone know, how to pass some variables on to php script in postwwwacct perl script and execute it with exec?
Thanks!
Does anyone know, if I can use perl and php together in postwwwacct or no? If not, does anyone know, how to pass some variables on to php script in postwwwacct perl script and execute it with exec?
Thanks!
I moved this post from http://forums.cpanel.net/f42/how-aut...on-148065.html to its own topic.
For hands-on assistance, please reference our new support information page: Where should I go for support?
cPResources: Support Options - Submit a ticket here - Additional Support Options - Forums Search - Mailing Lists(Alt) - Documentation
-- Jared Ryan, Technical Analyst, cPanel Technical Support
crinte, can you please provide more information about what you are trying to accomplish?
Hi crinte,
If I understand you correctly, you have a Perl postwwwacct script and you have PHP code that you want executed too? There is no good way to mesh the two into one script. It's be best to have the Perl fire a system() or exec() function (or something else) that calls the PHP code. Provided that the PHP doesn't have to be executed by Apache (or other webserver), here's a way to do it:
You could do something like this in your Perl postwwwacct script
Code:@args = ("/my/php/cli/script.php", "key1", "value1", "key2", "value2"); system(@args) == 0 or die "system @args failed: $?"
then you can use PHP code like this to store the key/value pairs into a PHP associative array
Regards,PHP Code:#!/bin/usr/php
//$argv is a special variable, http://php.net/manual/en/reserved.variables.argv.php
<?php
function argv2array ($argv) {
$opts = array();
$argv0 = array_shift($argv);
while(count($argv)) {
$key = array_shift($argv);
$value = array_shift($argv);
$opts[$key] = $value;
}
return $opts;
}
// test function!
$nice_array = argv2array($argv);
var_dump($nice_array);
-DavidN
David Neimeyer
Integration Developer
sdk.cpanel.net
APIs: XML-API API1 & API2
Check Out: Developer Downloads Integration Blog
Need Support? Support Ticket Developer Forum Feature Request
You may want to check out the PHP module: PHP - search.cpan.org It allows you to execute PHP code from Perl.
Alternatively, if you have simple PHP code, you can use PHP::Include: PHP::Include - search.cpan.org
Fortunity is correct, there are a few bridges out there. I did not mention them explicitly because I feel for this particular situation the benefit of using such a bridge is out weighted by the stability, safety, and ease of use when implementing a solution similar to the one I provided.
Crinte, the Perl code you're referring to would happen to be the postwwwacct script hook that Matt provided here. If so, you'll notice in that thread, I've updated it by posting a link to a blog post where, in detail, I explain how to write a PHP script hook that does MySQL database and user creation and privilege assignment all using the APIs.
Regards,
-DavidN
David Neimeyer
Integration Developer
sdk.cpanel.net
APIs: XML-API API1 & API2
Check Out: Developer Downloads Integration Blog
Need Support? Support Ticket Developer Forum Feature Request