473,804 Members | 3,068 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling perl script from PHP

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
5 7006
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
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
On Feb 22, 9:42 pm, Curtis <zer0d...@veriz on.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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2180
by: Mike Bobbitt | last post by:
I've recently decided to switch from compiled Apache/PHP to RPM's of both and I'm having a problem I can't seem to solve. I have a Perl script called php_include.cgi that parses a PHP file for inclusion. It does this by running "php -f " but unfortunately it no longer works with the RPM: ---------- Security Alert! The PHP CGI cannot be accessed directly. This PHP CGI binary was compiled with force-cgi-redirect enabled. This
2
4753
by: Shailan | last post by:
Hi Im having trouble with the following code that seems to be behave differently when called from the browser as opposed to the command line. The calling script is a cgi that forks, with the child trying to call another cgi script and pass arguments to it. It works fine from the command line, and calls the required script and passes the arguments correctly. However, when it is run on the browser, it calls the script but does not pass...
6
15904
by: Richard Trahan | last post by:
I want a js function to call a Perl script residing on a server. The Perl script will return a string, to be used by the js. Pseudo code: <script> stringvar = perlfunc_on_server(stringarg) document.write(stringvar) </script> Can stringvar above be a url?
3
5470
by: David Bear | last post by:
I have a hash function written by another organization that I need to use. It is implemented in perl. I've been attempting to decode what they are doing in their hash function and it is taking way too long. I've identified two functions in a perl module that I would like to 'call' from a python program. I found the following: http://www.annocpan.org/~GAAS/pyperl-1.0/perlmodule.pod and wondered if anyone had any comments. This thing...
4
11229
by: nidhikhandelwal | last post by:
I am calling a unix shell script from a perl script by using the following system command: system("./readfile_new.sh"); but it seems the unix script readfile_new.sh is not being called. Can someone let me know how to call this script in the perl file/
0
1524
by: brakesh | last post by:
Hi, I am trying to call a perl program (that connects a webserver database) from a php program via a webbrowser. For example : http://development.noaa.gov/test_exec.php?dataid=8313. The test_exec.php script that calls the perl program is as follows: <?php error_log("inside test_exec \n"); $dataid = $_GET; $cmd = "/usr/bin/perl /........../db_connect_psql_RS3.pl ". $dataid; error_log("dataid = $dataid\n"); exec($cmd); ?>
5
8661
by: davidr262 | last post by:
I am new to perl and need help with the following. In perl we are calling sqlplus with a PLSQL Script. In order to do this in PERL we had to do a system call. How do we return a error code from the PLSQL script back to the perl script?
1
1616
by: pragatid | last post by:
Hi, I am new to Perl programming. Let me explain my requirement over here. I have a Perl script located in /usr/sbin/ say script A and I want to invoke this script via web after accepting some user inputs. What I am thinking is , I will write a perl script(script B) which will invoke my script A and I will post my HTML form to script B. I will be using tomcat as a web server. Please guide me if this is going to work or let me know if there...
22
3471
by: Archanak | last post by:
Hi, I am using 2-level CSS Drop Down Menu in my perl/CGI program. here is the code. #!c:/perl/bin/perl.exe use CGI qw(:standard);
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9575
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10564
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10073
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9134
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7609
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5645
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.