You are here: Re: [PHP] passthru() passing variables « PHP « IT news, forums, messages
Re: [PHP] passthru() passing variables

Posted by "Richard Lynch" on 06/16/05 07:40

On Wed, June 15, 2005 5:36 pm, Chris Herold said:
> I have been told that in order to pass variables via passthru() to
> another script (in my case, a perl script) one can do the following ...
>
> passthru("home/test.cgi $var")
>
> and that $var will then be passed through to the cgi.
>
> I have tried this and failed.
>
> Is this the proper format or is there something that I am missing.

You may want to use exec first, so you can more easily capture the error
output and error codes.

exec("home/test.cgi $var", $output, $error);
if ($error){
//You should probably use error_log here in your real code...
//ASSUME this is going to break some day, for whatever reason.
//You'll need it logged unless you like dealing with error reports like:
//"Hey, the website broke yesterday."
echo "OS Error: $error<br />\n";
echo implode("<br />", $output);
exit;
}
echo $output;

Meanwhile, odds are *REALLY* good that you're not even calling the
test.cgi script because you haven't provide a path that PHP can use.

home/test.cgi would be assuming that home was in the same directory as
your PHP script, and even that is kinda iffy depending on where you do
this from the webserver or CLI...

I would recommend using FULL PATH to *everything* in exec (and passthru)

/full/path/to/home/test.cgi /full/path/to/any/args.txt

Also be sure to use the escapeshellargs function to make your $var data
kosher if it comes from the outside world.

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация