Forum Moderators: coopster

Message Too Old, No Replies

Capturing HTML output from external script

Not sure how to do this

         

MatthewHSE

9:21 pm on Feb 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have some CGI scripts on my website that just generate HTML code. I want to use that code on some PHP pages, but I can't figure out how to get at it.
include()
gets the Perl code for the scripts if I use the server path, and my host has disabled using full URL's (http://example.com) in PHP includes.

I tried

passthru()
, but my host has disabled that, too.

It sounds like

exec()
would do what I need, and it doesn't seem to be disabled. But apparently I don't know how to use it for this purpose, because I can't get it to return anything.

So back to the original question: How can I use PHP to execute a Perl script and print the HTML output?

Thanks in advance,

Matthew

ag_47

11:03 pm on Feb 28, 2009 (gmt 0)

10+ Year Member



You can try the curl library: [php.net...]
It should do exacty what you need

[edited by: eelixduppy at 11:51 pm (utc) on Feb. 28, 2009]
[edit reason] made URL a link [/edit]

rocknbil

5:44 pm on Mar 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Curl will work, but generally this is for external urls. If you have this perl script on your site, there's no reason to curl it.

So back to the original question: How can I use PHP to execute a Perl script and print the HTML output?

Did you try the system() [us.php.net] command?

The difference is exec doesn't store the output of the executed command (unless you use the output parameter,) system() does.

$perl_output = system('myscript.cgi');
print $perl_output; // or echo

rocknbil

8:26 pm on Mar 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



EDIT: Actually that is incorrect, it won't be the script output, it will be the last line of the system command. So while it won't store the entire page output in the variable, it may work for you.