Forum Moderators: coopster

Message Too Old, No Replies

Looking for a substitute for virtual()

I need it, but my host doesn't appear to support it

         

MatthewHSE

12:14 am on Dec 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm working on a PHP script that needs to pull in some HTML output generated by a Perl script. On my development server, I was able to do this with the virtual() function. But when I tried it on my production server (shared hosting), it threw an error about virtual() being an undefined function. So it looks like, for one reason or another, my host doesn't allow the use of that function.

So, are there any good substitutes? I know I can use include() and use the full http address of the file I want to use, but according to some posts around here, that's much slower than using the file system and I guess it clutters up server logs unnecessarily. So I'd rather not use that method. And obviously, using a relative path with include() just pulls in the Perl code itself instead of the output.

Any ideas will be appreciated.

Thanks in advance,

Matthew

MatthewHSE

1:33 am on Dec 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My host pointed me toward a couple workarounds for this, but neither of them work in this case. You're supposed to be able to use these instead of a single virtual() call. Here they are:

// Code to replace virtual() call
putenv('REQUEST_METHOD=GET');
putenv('QUERY_STRING=whatever');
passthru('/full/path/to/perl/script.cgi');

exec('/full/path/to/perl/script.cgi', $output);
array_shift($output); // remove first line
echo(join('', $output)); // output contents

The result of both of those is a Perl "Software Error" message, giving details about being unable to find a file that is included in the Perl script like this:

[B]use ABC::StandardModule;[/B]
. I don't know anything about Perl, but I'm guessing that's the equivalent of require() in PHP. At any rate, I can go directly to the Perl script with my browser and it gives me the HTML output, but trying to get it into this PHP script is failing.

Just an update - all ideas will still be most welcome! ;)

Thanks again,

Matthew

coopster

9:58 pm on Dec 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I suppose you could open your own socket and post a request, then read the contents back in and parse them (fsockopen() [php.net]).
Another option might be to convert the perl code to php.