dirk

What's the best method of executing a

Perl

  script from

PHP

 ?

I simply have to trigger a

Perl

  script when a

PHP

  script is executed.

No passing of variables is required.

I have testet virtual('/cgi-bin/test.cgi') which is normally working.

But it's not running if there is a redirect in the

PHP

  script.

perkiset

Hey Dirk -

exec('

perl

  /aDir/aFile.pl');

will just run it, you'll be waiting while it gets done. Obviously, if you do a > /dev/null & at the end of that command then it will run in the background and return immediately.

If you need the results from stdio of the

PHP

  script, then you should do $aVar = shellexec() which will both wait for the script and bring the results from stdio into the variable $aVar.

Hope that does it,
/p

dirk

Hi Ed,

just tested it. It's working fine.

Thanks!

perkiset

No worries!

/p

JasonD

Just in case you are using a varible to trigger the exec make sure you are VERY careful.

Nasty bastards can easily manipulate this with form fields containing information such as.


;exit;cat /etc/passwd;

dirk

Yes, thanks.

That's generally a problem, for example also with SQL injections.

Would be interesting to compare

Perl

  with

PHP

  regarding the injections.

perkiset

quote author=JasonD link=topic=256.msg1801#msg1801 date=1180345801

Just in case you are using a varible to trigger the exec make sure you are VERY careful.


SSSssssshhhhhhh! C'mon man!  Applause Applause Applause

Actually Dirk, the most effective way of doing this is running the exec() with a $var gathered from a GET parameter.

Trust me on this one  Applause

/p

JasonD

It's not a

perl

  or

php

  issue but rather a bad

programming

  issue using whatever language happens to float your boat.

Perk, I'll keep schtum next time Applause

perkiset

<i>( Wonders if JD reads Perk's posts as the sarcastic horsecrap that they are... )</i>

JasonD

possibly Applause


Perkiset's Place Home   Politics @ Perkiset's