in reply to Passing variables from PHP to Perl using passthru()

Although this is a PHP question and not a perl:

The passthru() function allows a second parameter only to store the results of the function call, system() is the same.

Pass the params inside the call, like
passthru("/home/test.cgi $var",$result);

Don
WHITEPAGES.COM | INC

Edit by castaway: Closed small tag in signature

Replies are listed 'Best First'.
Re^2: Passing variables from PHP to Perl using passthru()
by cdherold (Monk) on Jun 16, 2005 at 21:40 UTC
    I tried

    passthru("/home/test.cgi $var",$result);

    without success. Is there something that I may have to do to the variable, on exit from php or on entry to perl, to make perl think the variable has been "scrubbed clean" and not subject to tainting by outsiders?

      I was able to duplicate this as written above. Two notes though:

      1) passthru() will work as described above, but the the value stored in the $result will be the exit status of the program. If it is not zero, the program did not run. If it is 127, it could not find the program. As well, passthru() is typically used for binary or raw data: use exec('command','output var','return code') to store the data retrieved form the executed command and system('command','return code') to print string data out as retrieved.

      2) the results of those commands are affected by the INI_SYSTEM values of safe_mode and safe_mode_exec_dir. If safe_mode is set to yes, executable are only allowed in the safe_mode_exec_dir.

      Don
      WHITEPAGES.COM | INC

      Edit by castaway: Closed small tag in signature

        I found out what I was doing wrong. I had to grab the value sent by the php program to the perl script. The following worked ...

        PHP Script: <? $var = 1; passthru(/home/test.cgi $var); ?> PERL Script(test.cgi): #!/usr/bin/perl print "Content-type: text/html\n\n"; $var = $ARGV[0]; print "Value: $var"; OUTPUT: Content-type: text/html Value: 1

        wee hee!