Params passing to the standalone executable ????

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wvdploeg
Forum Newbie
Posts: 1
Joined: Thu May 08, 2003 3:55 pm

Params passing to the standalone executable ????

Post by wvdploeg »

[Admin Edit: moved from the register_globals sticky]

Ok, I do not know if it's possible AT ALL, but I want to do some stresstesting of some php scripts intended to be on the internet, but testing them offline by passing them to the PHP executable... it works great, only I do not have the faintest idea how to pass parameters.
So
php.exe -f test.php gives the output I expected, but when 'test.php' expects some variables (normally coming from posting/getting the vars), it does not work... How do I 'fool' the commandline and make it think it's invoked by a webserver ??????

Even a simple script like

Code: Select all

<?php
  echo $test;
?>
does not work

I use 4.2 on Windows...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

the cgi specification can be found at http://hoohoo.ncsa.uiuc.edu/cgi/interface.html
You have to set some environment variables and maybe pass data to the input descriptor. Can be done in a batch (or .cmd) file
e.g.

Code: Select all

set GATEWAY_INTERFACE=CGI/1.0
...
php test.php < echo "a=1&b2"
(completely untested)
note that echo $test; might not work anyway for php 4.2+ (see also: http://forums.devnetwork.net/viewtopic.php?t=511)
muab
Forum Newbie
Posts: 3
Joined: Thu May 08, 2003 3:38 pm

Post by muab »

volka wrote:the cgi specification can be found at http://hoohoo.ncsa.uiuc.edu/cgi/interface.html
umm, this doesnt mention how to use the php.exe (or am i so blind?)
volka wrote:

Code: Select all

set GATEWAY_INTERFACE=CGI/1.0
...
php test.php < echo "a=1&b2"
(completely untested)
as soon i append the part '< echo "a=1&b2"' windows (well, dos) does tell me that the file doesnt exist.

greez
muaB
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

oops, php ... < cmd doesn't work on win32.
nope, http://hoohoo.ncsa.uiuc.edu/cgi/interface.html doesn't tell you how to use php.exe but how to pass parameters to a cgi-application (like php if you want $_GET, $_POST, ...)
this one works for me

Code: Select all

set SERVER_SOFTWARE=batch/1.0
set SERVER_NAME=console
set GATEWAY_INTERFACE=CGI/1.1
set SERVER_PROTOCOL=HTTP/1.0
set SERVER_PORT=23

set SCRIPT_NAME=test.php
set REQUEST_METHOD=POST
set PATH_INFO=/test.php
set PATH_TRANSLATED=/test.php
set QUERY_STRING=g=viaGet
rem set REMOTE_HOST=127.0.0.1
set REMOTE_ADDR=127.0.0.1
rem set AUTH_TYPE
rem set REMOTE_USER
rem set REMOTE_IDENT
set HTTP_USER_AGENT=me 1/0 1/0
set CONTENT_TYPE=application/x-www-form-urlencoded
set CONTENT_LENGTH=8

echo p=posted | php.exe test.php
pause
although it's probably not completely correct php can handle my ignorance ;)
Post Reply