By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,669 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

Calling perl script from PHP

P: n/a
Hi.

I need to develop a web based application which uses php for the front
end and statistical manipulations in perl - my question is - how do i
call a perl script from php - i guess the answer is gonna be exec. I
cant seem to understand how can i pass variables from the PHP script
to the Perl script and vice versa using exec? Is there a better way to
go about it?

Rahul

Feb 23 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
rahulthathoo wrote:
Hi.

I need to develop a web based application which uses php for the front
end and statistical manipulations in perl - my question is - how do i
call a perl script from php - i guess the answer is gonna be exec. I
cant seem to understand how can i pass variables from the PHP script
to the Perl script and vice versa using exec? Is there a better way to
go about it?

Rahul
The wonders of Google:
http://devzone.zend.com/node/view/id/1712

--
Curtis, http://dyersweb.com
Feb 23 '07 #2

P: n/a
Apart from this, another question that I had was - once the perl
script is done running - and has completed successfully, how do i know
in the php script that this has happened - coz i need to do something
the moment it(perl script) finished exection?

Rahul


Feb 23 '07 #3

P: n/a
On Feb 22, 9:42 pm, Curtis <zer0d...@verizon.netwrote:
rahulthathoo wrote:
Hi.
I need to develop a web based application which uses php for the front
end and statistical manipulations in perl - my question is - how do i
call a perl script from php - i guess the answer is gonna be exec. I
cant seem to understand how can i pass variables from the PHP script
to the Perl script and vice versa using exec? Is there a better way to
go about it?
Rahul

The wonders of Google:http://devzone.zend.com/node/view/id/1712

--
Curtis,http://dyersweb.com

Oh actually i saw this already, but this is not stable as they say. So
I dont want to use this.

Rahul

Feb 23 '07 #4

P: n/a
rahulthathoo wrote:
I cant seem to understand how can i pass variables from the PHP script
to the Perl script and vice versa using exec?
You could store all your variables in one big array, serialize() the
array, and then pass it to Perl as STDIN. In Perl, you can then use Scott
Hurring's implementation[1] of unserialize() to retrieve the data.

Passing data back, again, in Perl bundle the data up into a Perl hash,
serialize() it using Hurring's module, and then print it to STDOUT. PHP
reads the STDOUT and unserializes the data.

Easy peasy.

____
1. http://hurring.com/code/perl/serialize/

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Feb 23 '07 #5

P: n/a
Toby A Inkster wrote:
rahulthathoo wrote:
>I cant seem to understand how can i pass variables from the PHP script
to the Perl script and vice versa using exec?

You could store all your variables in one big array, serialize() the
array, and then pass it to Perl as STDIN. In Perl, you can then use Scott
Hurring's implementation[1] of unserialize() to retrieve the data.

Passing data back, again, in Perl bundle the data up into a Perl hash,
serialize() it using Hurring's module, and then print it to STDOUT. PHP
reads the STDOUT and unserializes the data.

Easy peasy.

____
1. http://hurring.com/code/perl/serialize/
Ah, that's very cool. That's a very clever way to communicate data. :)

--
Curtis, http://dyersweb.com
Feb 23 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.