...

View Full Version : Require a perl file from within a php page



rockdoc
11-10-2007, 01:50 PM
Ive been using this code on a linux / cpanel server to include a perl file within a php page

require("http://www.mysite.com/cgi-bin/file.pl");

I noticed that it only worked when I used the absolute url rather than a relative url

Anyway, I changed webservers to another cpanel package with a different host and the above code does not work anymore.

Does anyone have any suggestions?

Inigoesdr
11-10-2007, 04:13 PM
Anything more informative than "doesn't work"? Have you tried to load the perl page in your browser to see the output? It's possible that your new host has fopen wrappers disabled. There's nothing wrong with the code itself as long as the path is correct.

Edit: Put this code in a php page to see if your host allows fopen wrappers and including from them:

echo 'allow_url_fopen: ' . ini_get('allow_url_fopen') . '<br />allow_url_include: ' . ini_get('allow_url_include');

rockdoc
11-11-2007, 04:38 AM
Sorry, I forgot I had error messaging disabled.

Here are the error messages...

Warning: require() [function.require]: URL file-access is disabled in the server configuration

Warning: [function.require]: failed to open stream: no suitable wrapper could be found in.

I used your code...
allow_url_fopen is enabled

BUT

allow_url_include is disabled,

My host informed me that they would not enable allow_url_include

Inigoesdr
11-11-2007, 05:24 AM
Yeah, you won't be able to use that code like that. You should be able to use something like this though, since url_fopen is enabled:

echo file_get_contents('http://www.mysite.com/cgi-bin/file.pl');

rockdoc
11-11-2007, 01:55 PM
Thanks Inigoesdr,

However, file_get_contents just displays the contents of the perl file - it does not interpret it. (it also can't handle any query string e.g. file.pl?display=today)


I'll keep playing around with it... I'm open to any other suggestions you or anyone else has.

Inigoesdr
11-11-2007, 06:26 PM
If you use a URL for the path it should be interpreted by the server before it's sent to your PHP script.

rockdoc
11-12-2007, 09:46 AM
Ok, all sorted now.

Really appreciated your help with this Inigoesdr.

I also sorted out the query string issue-I had variables in the string (example below)

echo file_get_contents('http://www.mysite.com/cgi-bin/file.pl?display=' . $today . '&time=' . $time);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum