1

I have a perl script, which takes a query string parameter, connects to a database and displays data.

I'd like to include that script in a PHP file like so:

include('perlscript.pl?item=302');

Such that the perl script's response is displayed on the PHP/HTML page.

How can I do this?

2 Answers 2

1

With backticks?

echo `/path/to/perl perlscript.pl item=302`
Sign up to request clarification or add additional context in comments.

1 Comment

If the 302 is coming from the query, this may leave you wide open to shell injection! Unfortunately PHP has no safe execution mechanism; you'll have to escapeshellarg manually.
0

If safe_mode is on or shell_exec is disabled, one option is to fetch the content of your script using fopen() or using curl.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.