简体   繁体   中英

Calling Perl script with PHP, passing variables and put result into a file

I am near losing my mind cause of a perl script I want to call via PHP.

I have a PHP Form where I put in a MySQL Query which gets stored in a file and choosing some variables.

If I call any SHELL command like "top" ... everything works fine, but as soon as I try to call my perl script with variables, there are no results at all.

The file where the results should get stored stays empty.

That's the calling part from the PHP File:

if (isset($_POST['submit'])) {
$file = 'query.sql';
$query = $_POST['query'];
file_put_contents($file, $query);
$command = "perl /home/www/host/html/cgi/remote-board-exec.pl -sqlfileexec query.sql > /home/www/host/html/cgi/passthrutest.txt";
exec($command, &$ausgabe, $return_var);

There is no error message and i already tried debug things, but nothing helped :(

Are you sure that perl is being executed? Perhaps you ought to replace the command with 'which perl' just to make sure, and to use the full path to Perl. Another idea is to make sure your:

  • perl script is executable (use chmod)
  • ensure it has '#!/usr/bin/perl' (or wherever your path to perl is)
  • change the command to "/home/www/host/cgi/remote-board-exec.pl..." without the perl command
  • dump the contents of your output array ($ausgabe) as if the command fails to execute you may find out what is happening.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM