| re: Best way to run a perl script from php on windows?
Uzytkownik "Justin" <usernet@soupisgoodfood.network> napisal w wiadomosci
news:GVR7c.3011$u%1.431646@news02.tsnz.net...[color=blue]
> I've played around quite a bit with PHP prog exec functions, but having
> problems getting an output, or getting it to run the script full-stop most
> of the time, and have no idea how I'm supposed to pass the HTML/data to[/color]
it.[color=blue]
>
> I'm running windows BTW, so that's probably half the problem.
>
> Does anyone know what the best way to approach this is? Any good tutorials
> specificly for passing/outputting data from command-line run perl scripts?
> Can't seem to find anything.[/color]
Presumably the PERL script grabs the HTML from stdin. It'd be pretty hard
for PHP to communicate directly with the PERL process, as the PHP API
haven't include low level interprocess functions. With a bi-directional pipe
you run the risk of the two deadlocking. The more reliable--though not very
elegant--solution is to write the HTML into a temp file, pipe it into the
PERL script, and capture the output:
$tempfile = tempnam();
file_puts_contents($tempfile, $html);
$output = `perl < "$tempfile"`; |