Calling (non-php) scripts from inside PHP

This is a discussion on Calling (non-php) scripts from inside PHP within the PHP Language forums, part of the PHP Programming Forums category; In my php page I am calling a Python cgi. The problem is that originally the Python script was being ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-12-2007
Anthony Smith
 
Posts: n/a
Default Calling (non-php) scripts from inside PHP

In my php page I am calling a Python cgi. The problem is that
originally the Python script was being called directly and it could
access the environment variables that were being set. Now since the
php script is being called first it has access to the environment
variables, but the Python script does nt.

How can I forward the variables or call the Python script in such a
way where it can access those variables?

These are the type of environment variables I am talking about
$_SERVER['HTTP_OBREQUESTEDURL']

In my php script (which is a web page) I was calling the Python cgi
like this.
$output=shell_exec("../cgi-bin/setaccess.cgi"." 2>&1"); //system call
print $output;

Reply With Quote
  #2 (permalink)  
Old 12-12-2007
AnrDaemon
 
Posts: n/a
Default Re: Calling (non-php) scripts from inside PHP

Greetings, Anthony Smith.
In reply to Your message dated Wednesday, December 12, 2007, 22:30:55,

> In my php page I am calling a Python cgi. The problem is that
> originally the Python script was being called directly and it could
> access the environment variables that were being set. Now since the
> php script is being called first it has access to the environment
> variables, but the Python script does nt.


> How can I forward the variables or call the Python script in such a
> way where it can access those variables?


> These are the type of environment variables I am talking about
> $_SERVER['HTTP_OBREQUESTEDURL']


> In my php script (which is a web page) I was calling the Python cgi
> like this.
> $output=shell_exec("../cgi-bin/setaccess.cgi"." 2>&1"); //system call
> print $output;


If it is really CGI script, why not call it using CGI? Direct URL-include or
some dance with cURL or socket read?

Aside from that, You can try use putenv() to temporarily alter the environment
before starting external application. Altered environment should be passed to
it, I guess.


--
Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru>

Reply With Quote
  #3 (permalink)  
Old 12-13-2007
NC
 
Posts: n/a
Default Re: Calling (non-php) scripts from inside PHP

On Dec 12, 11:30 am, Anthony Smith <mrsmi...@hotmail.com> wrote:
>
> In my php page I am calling a Python cgi. The problem is that
> originally the Python script was being called directly and it could
> access the environment variables that were being set. Now since the
> php script is being called first it has access to the environment
> variables, but the Python script does nt.
>
> How can I forward the variables or call the Python script in such a
> way where it can access those variables?
>
> These are the type of environment variables I am talking about
> $_SERVER['HTTP_OBREQUESTEDURL']
>
> In my php script (which is a web page) I was calling the Python cgi
> like this.
> $output=shell_exec("../cgi-bin/setaccess.cgi"." 2>&1"); //system call
> print $output;


This might work:

readfile('http://localhost/cgi-bin/setaccess.cgi');

Cheers,
NC
Reply With Quote
  #4 (permalink)  
Old 12-13-2007
Anthony Smith
 
Posts: n/a
Default Re: Calling (non-php) scripts from inside PHP

On Dec 12, 7:22 pm, NC <n...@iname.com> wrote:
> On Dec 12, 11:30 am, Anthony Smith <mrsmi...@hotmail.com> wrote:
>
>
>
>
>
> > In my php page I am calling a Python cgi. The problem is that
> > originally the Python script was being called directly and it could
> > access the environment variables that were being set. Now since the
> > php script is being called first it has access to the environment
> > variables, but the Python script does nt.

>
> > How can I forward the variables or call the Python script in such a
> > way where it can access those variables?

>
> > These are the type of environment variables I am talking about
> > $_SERVER['HTTP_OBREQUESTEDURL']

>
> > In my php script (which is a web page) I was calling the Python cgi
> > like this.
> > $output=shell_exec("../cgi-bin/setaccess.cgi"." 2>&1"); //system call
> > print $output;

>
> This might work:
>
> readfile('http://localhost/cgi-bin/setaccess.cgi');
>
> Cheers,
> NC


I ended up doing this:
header("Location: http://wsso.prod.fedex.com/VCP/cgi-bin/setaccess.cgi");

In the PHP file I can have other code, but as long as it does not have
any header information, I might be fine. I basically needed the
ability to set the cookie and put things into the session.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:33 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0