Professional Web Applications Themes

ENV variables in perl scripts called from perl. - PHP Development

The subject says it all. I am doing a: I have a perl script in which I am using a ReadP routine that ps 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 ...

  1. #1

    Default 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 ReadP routine that ps 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 cirvent 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]
    Sandman Guest

  2. #2

    Default Re: ENV variables in perl scripts called from perl.

    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 ReadP routine that ps 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 cirvent 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!
    >
    Terence Guest

  3. #3

    Default Re: ENV variables in perl scripts called from perl.

    In article <3f1f8b1a$1cicada>, Terence <tk.listsfastmail.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]
    Sandman Guest

Similar Threads

  1. Effeciency question - perl scripts v's perl exe's
    By Steffen Müller in forum PERL Miscellaneous
    Replies: 2
    Last Post: September 2nd, 10:57 AM
  2. Perl scripts interconnectivity... Is it possible...
    By Roman Khutkyy in forum PERL Miscellaneous
    Replies: 4
    Last Post: August 14th, 01:16 AM
  3. Perl / Cgi scripts in colour
    By Jared in forum Macromedia Dreamweaver
    Replies: 2
    Last Post: August 4th, 05:00 AM
  4. Invoking perl and .cgi scripts
    By Gary White in forum Macromedia Dreamweaver
    Replies: 4
    Last Post: July 20th, 06:48 PM
  5. include ASP scripts in PERL
    By Richard Gration in forum PERL Miscellaneous
    Replies: 1
    Last Post: July 2nd, 05:36 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139