473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

ENV variables in perl scripts called from perl.

The subject says it all. I am doing a:

I have a perl script in which I am using a ReadParse routine that parses the
$ENV{'QUERY_STRING'} or $ENV{'CONTENT_LENGTH'}*which are two variables passed
to the script under usual SSI (.shtml) containing form data submitted to the
page from which the script is executed from.

Well, since switching to PHP, I have moved most of my perl scripts to php
equivalents, but there are a few perl scripts that are just too big for me to
try to convert them, and I am unsure if what they do could even be accomplished
by PHP. So I am going to continue to use them. The problem, though, is that
when I use...

print shell_exec("script.pl");

....to execute the scripts, these environment variables aren't passed and the
script cannot perform it's task. Is there a way to circumvent this, and pass
these through?

I have found that doing this is my perlscript:

foreach (keys %ENV){
print "$_ -> $ENV{$_}<br>";
}

Outputs alot of variables, where one reads:

HTTP_SERVER_VARS -> Array

I suspect that this $ENV variable might be an array of all my wanted ariables,
allthough I must confess that I do not know how to list them or use them, if
so. I tried...

print $ENV{'HTTP_SERVER_VARS'}{'QUERY_STRING'};

....but that yielded nothing. So I am at loss, and I am hoping someone out there
has a solution for my predicament.

Thank you in advance!

--
Sandman[.net]
Jul 16 '05 #1
2 5052
You perl script will NEVER inherit the environment of the calling PHP
script. You will have to serialise the data from PHP to a place where
perl can find it.

one option is to store wddx string which you can then "pipe" to the perl
script which will then need a routine to deseriliase it from wddx.

you may have to use popen() or proc_open()

also check out the wddx functions. I only suggest that because it is
cross-language and simple. you could also use XML-RPC packets but that
would be more involed.

see if there is a perl function which can "deserialize()" a PHP
"serialize()". If so (unlikely), this would be most efficient (easiest)

use piping. you don't want to mess around with writing temporary files
and race conditions etc...

Sandman wrote:
The subject says it all. I am doing a:

I have a perl script in which I am using a ReadParse routine that parses the
$ENV{'QUERY_STRING'} or $ENV{'CONTENT_LENGTH'} which are two variables passed
to the script under usual SSI (.shtml) containing form data submitted to the
page from which the script is executed from.

Well, since switching to PHP, I have moved most of my perl scripts to php
equivalents, but there are a few perl scripts that are just too big for me to
try to convert them, and I am unsure if what they do could even be accomplished
by PHP. So I am going to continue to use them. The problem, though, is that
when I use...

print shell_exec("script.pl");

...to execute the scripts, these environment variables aren't passed and the
script cannot perform it's task. Is there a way to circumvent this, and pass
these through?

I have found that doing this is my perlscript:

foreach (keys %ENV){
print "$_ -> $ENV{$_}<br>";
}

Outputs alot of variables, where one reads:

HTTP_SERVER_VARS -> Array

I suspect that this $ENV variable might be an array of all my wanted ariables,
allthough I must confess that I do not know how to list them or use them, if
so. I tried...

print $ENV{'HTTP_SERVER_VARS'}{'QUERY_STRING'};

...but that yielded nothing. So I am at loss, and I am hoping someone out there
has a solution for my predicament.

Thank you in advance!


Jul 16 '05 #2
In article <3f1f8b1a$1@cicada>, Terence <tk******@fastmail.fm> wrote:
You perl script will NEVER inherit the environment of the calling PHP
script. You will have to serialise the data from PHP to a place where
perl can find it.


Are you for real? Why is this true?

Pardon me for saying this - but that would be a mayor PITA...

--
Sandman[.net]
Jul 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
by: Fred Ma | last post by:
Hello, This is not a troll posting, and I've refrained from asking because I've seen similar threads get all nitter-nattery. But I really want to make a decision on how best to invest my time....
4
by: Florian Lindner | last post by:
Hello, given the following situation: I have a script which is readable and executable by a user, but not writable. The users executes the scripts, it reads in a value and based on this value...
1
by: Joe | last post by:
I am trying to write a Perlscript to be used with some HTML pages. Here is how it works: 1.. The first HTML page has a form which requests for user input. Then it passes the QUERY_STRING...
1
by: Ronnie Laurikkala | last post by:
In e.g. a Bourne shell script I can source variables and values; #!/bin/sh .. ${HOME}/script_common_lib How can I source variables and values from a file and use them in Perl-scripts? ...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
12
by: rurpy | last post by:
Is there an effcient way (more so than cgi) of using Python with Microsoft IIS? Something equivalent to Perl-ISAPI?
0
by: Reedick, Andrew | last post by:
<snip> I have a Perl background and have found the O'Reilly books to be useful. The Learning Python book (or whatever it's called) is good because it covers the paradigm shifts and potential...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
6
KevinADC
by: KevinADC | last post by:
This snippet of code provides several examples of programming techniques that can be applied to most programs. using hashes to create unique results static variable recursive function...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.