Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Aug 2004
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Require a perl file from within a php page

    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?

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    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:
    PHP Code:
    echo 'allow_url_fopen: ' ini_get('allow_url_fopen') . '<br />allow_url_include: ' ini_get('allow_url_include'); 
    Last edited by Inigoesdr; 11-10-2007 at 03:18 PM.

  • #3
    New Coder
    Join Date
    Aug 2004
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    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:
    PHP Code:
    echo file_get_contents('http://www.mysite.com/cgi-bin/file.pl'); 

  • #5
    New Coder
    Join Date
    Aug 2004
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    If you use a URL for the path it should be interpreted by the server before it's sent to your PHP script.

  • #7
    New Coder
    Join Date
    Aug 2004
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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);


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •