Forum Moderators: coopster

Message Too Old, No Replies

how to run a perl script from php (on a webpage)

         

schulerlab

2:24 am on Jul 28, 2008 (gmt 0)

10+ Year Member



I am not that familiar with PHP, but am learning it as I go along.

I just put up a Drupal site, which is a PHP driven Content Management system.

I would like to create a block (a block of html that can contain php to be placed on predesignated pages) where I use PHP to call a Perl script.

at the present time, I am using javascript, but I would like to know how to do this in PHP.

The javascript that I am currently using executes a Perl script that picks up a random post from a forum (perl driven forum), formats a "teaser" with a link to that post, and displays it on the webpage containing the javascript.

How would I do the same thing using PHP?

I am on shared hosting.

Thanks.

eelixduppy

6:13 pm on Jul 28, 2008 (gmt 0)



Well if the perl script returns the formatted link then you should be able to just grab the output from it, no? Something like this:

echo [url=http://www.php.net/file-get-conents]file_get_contents[/url]('http://www.example.com/path/to/script');

Make sure to use the URL version of the path so that the script is parsed first.

schulerlab

9:13 am on Jul 29, 2008 (gmt 0)

10+ Year Member



well, I put this on a webpage:
<div><?php
echo [url=http://www.php.net/file-get-contents]file_get_contents[/url]('http://www.mysite.com/cgi-bin/av/rpost_arc.pl?js=5');
?></div>

and I get this when I try to execute it

Parse error: syntax error, unexpected '[' in /home/mysite/public_html/includes/common.inc(1537) : eval()'d code on line 2

?

eelixduppy

11:48 am on Jul 29, 2008 (gmt 0)



Is this file you put the code above called common.inc? Seemns odd you are getting this error.

schulerlab

4:50 pm on Jul 29, 2008 (gmt 0)

10+ Year Member



I don't have "common.inc" in the html, nor in the perl script.

am I supposed to call "common.inc" in this block of php code that I placed in the middle of this html page?

I tried using this method previously, tried their "example 3":
[devzone.zend.com...]

but my host didn't have this php extension installed, and when I asked for it, they wouldn't do it. They said they don't because

it's not really practical for us to install PHP extensions on our shared servers - every time the server is updated, it wipes out any custom PHP configuration, so the extension would automatically remove itself after a random amount of time - possibly a few days, weeks etc. That's probably not good if you'd be using the script on a live site.

I am on shared hosting and don't know how to install this extension just on my site.. so, I thought I would try to find another method.

schulerlab

5:51 pm on Jul 29, 2008 (gmt 0)

10+ Year Member



ok... I copied over a random image generator "php within html" block that I use for gallery.

the new block of "php within HTML" looks like this:


<div>
<?php
$ch = curl_init();
$timeout = 0; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://www.owenfoundation.com/cgi-bin/av/rpost_arc.pl?js=5');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
echo $file_contents;
?>
<em><span style="font-size: 12px">random posts</span></em></div>

and I'm getting the output... but, it is enclosed with this:

document.write('Another View Archive
Total Number of Archived Posts = 11433

--------------------------------------------------------------------------------
Random Posts:

*Maddy, here is a link... Link in Post - Lynne

*Salmon Bill! Link in Post - Cheryl

*Good thing I don't.... - Karen

*Bill-what a joy... - Nancy A+ ns

*Please do continue applause - Maggie
');
random posts

how can I remove the "document write('...')" from the code?