The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 22, 2019, 08:13:43 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Execution of Perl Scripts  (Read 4391 times)
dirk
Global Moderator
Expert
*****
Offline Offline

Posts: 416


View Profile
« on: May 21, 2007, 01:58:01 PM »

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.
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: May 21, 2007, 02:20:46 PM »

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
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
dirk
Global Moderator
Expert
*****
Offline Offline

Posts: 416


View Profile
« Reply #2 on: May 21, 2007, 02:49:04 PM »

Hi Ed,

just tested it. It's working fine.

Thanks!
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: May 21, 2007, 02:53:28 PM »

No worries!

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
JasonD
Expert
****
Offline Offline

Posts: 100


View Profile
« Reply #4 on: May 28, 2007, 02:50:01 AM »

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.

Code:
;exit;cat /etc/passwd;
Logged
dirk
Global Moderator
Expert
*****
Offline Offline

Posts: 416


View Profile
« Reply #5 on: May 28, 2007, 07:25:38 AM »

Yes, thanks.

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

Would be interesting to compare Perl with PHP regarding the injections.
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #6 on: May 28, 2007, 08:24:03 PM »

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

SSSssssshhhhhhh! C'mon man!  ROFLMAO ROFLMAO ROFLMAO

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  Devilish

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
JasonD
Expert
****
Offline Offline

Posts: 100


View Profile
« Reply #7 on: May 30, 2007, 05:29:35 AM »

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 Smiley
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #8 on: May 30, 2007, 09:31:40 AM »

( Wonders if JD reads Perk's posts as the sarcastic horsecrap that they are... )
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
JasonD
Expert
****
Offline Offline

Posts: 100


View Profile
« Reply #9 on: June 01, 2007, 07:51:09 AM »

possibly Cheesy
Logged
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!