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

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?

Replies are listed 'Best First'.
Re^3: Passing variables from PHP to Perl using passthru()
by BaldPenguin (Friar) on Jun 17, 2005 at 06:17 UTC
    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!