Re: [PHP] Windows ENV['_'] equivalent

2006-10-16 Thread Stut

Richard Lynch wrote:

On Sat, October 14, 2006 4:09 am, Stut wrote:

Richard: AFAIK there is no way to know this under windows without
writing an extension to tell you.


Sounds like you actually know how to do this... :-)

Would such an extension be cross-platform to all PHP installs, or
Windows-only?

And is this some trivial thing that the PHP Devs just havent' had time
to do, or some monumental task of goofy OSes that nobody wants to
touch?

I'm happy to take a shot at it if it's easy, but if it's something the
PHP Devs don't want to touch, I know I ain't got a shot at it! :-)


I've not looked at the CLI SAPI at all yet, so I don't know if it gets 
put anywhere, but the SAPI main() function will get what you want passed 
to it. I guess now's as good a time as any...


Hey, whaddya know, it does. Check out [1]. Not sure how you'd get to 
that in an extension, but it's there. Since it's not linked that's a 
pretty good sign that that particular member of the struct is not used 
anywhere. In fact, looking at the usage of that var [2] it may not be 
available outside the SAPI code.


However, looking a bit further [3] it's defined as a static var in 
php_cli.c, so you may be able to get at it with an extern declaration. 
You should get the full path to the binary from the CLI module, looks 
like it's NULL for any SAPI that doesn't set it. However, it was never 
going to be that simple. It looks like that struct has a different name 
in each SAPI, so you may need to do something to mod the code if it's 
not building the CLI SAPI.


Should be able to knock something up armed with that. And yes, it should 
be the same code for all platforms. I'd love to have a go at this myself 
(just for fun), but unfortunately I don't have a great deal of spare 
time at the moment. Let me know how you get on.


[1] http://lxr.php.net/source/php-src/sapi/cli/php_cli.c#691
[2] http://lxr.php.net/ident?i=cli_sapi_module
[3] http://lxr.php.net/source/php-src/sapi/cli/php_cli.c#368

-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Windows ENV['_'] equivalent

2006-10-16 Thread Richard Lynch
On Mon, October 16, 2006 4:41 pm, Roman Neuhauser wrote:
> Just a thought: var_dump(ini_get('register_argc_argv')) ?

I should have been more clear

If/when there are any $args, then $argc/$argv are set:
$ /cygdrive/c/php5.1.1/php.exe -q argv.php
array(1) {
  [0]=>
  string(8) "argv.php"
}

C:\Documents and Settings\rlynch>c:\php5.1.1\php.exe -q
K:\pizzahut\argv.php
array(1) {
  [0]=>
  string(20) "K:\pizzahut\argv.php"
}

But $argv does not contain the path of the binary PHP running -- it
has everything AFTER that in the command line.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Windows ENV['_'] equivalent

2006-10-16 Thread Richard Lynch
On Sat, October 14, 2006 4:09 am, Stut wrote:
> Richard: AFAIK there is no way to know this under windows without
> writing an extension to tell you.

Sounds like you actually know how to do this... :-)

Would such an extension be cross-platform to all PHP installs, or
Windows-only?

And is this some trivial thing that the PHP Devs just havent' had time
to do, or some monumental task of goofy OSes that nobody wants to
touch?

I'm happy to take a shot at it if it's easy, but if it's something the
PHP Devs don't want to touch, I know I ain't got a shot at it! :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Windows ENV['_'] equivalent

2006-10-16 Thread Richard Lynch
On Mon, October 16, 2006 9:04 am, Jochem Maas wrote:
> 2. try making use of the $_ENV['PHP_PEAR_PHP_BIN'] value which should
> be
> configured if pear is installed properly. (it's there in my local
> setup

C:\Documents and Settings\rlynch>C:\php5.1.1\php.exe -a
Interactive mode enabled



Notice: Undefined index:  PHP_PEAR_PHP_BIN in C:\Documents and
Settings\rlynch\- on line 1



C:\Documents and Settings\rlynch>


[EMAIL PROTECTED] /cygdrive/k/pizzahut/tests
$ /cygdrive/c//php5.1.1/php.exe  -a
Interactive mode enabled



Notice: Undefined index:  PHP_PEAR_PHP_BIN in k:\pizzahut\tests\- on
line 1


^D

[EMAIL PROTECTED] /cygdrive/k/pizzahut/tests



Apparently, PEAR is not correctly installed when I snag php5.1.1 and
dump it into c:\php5.1.1 and run CLI.  Since I seldom use PEAR, I've
never noticed this before.

I'm fairly confident that var_dump($_ENV) did not output any key/value
that had anything useful to my needs -- I scoured that pretty
carefully, as it's where I expected my answer to be.  Ditto for
$_SERVER.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Windows ENV['_'] equivalent

2006-10-16 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-16 14:28:41 -0500:
> On Fri, October 13, 2006 7:44 pm, Roman Neuhauser wrote:
> > # [EMAIL PROTECTED] / 2006-10-13 13:53:56 -0500:
> >> So, I have this automated testing script I wrote, and I want to make
> >> it work on more than just my computer.
> >>
> >> In cygwin, and in Linux, EVN['_'] has the nice path to the binary
> >> CLI
> >> which is running -- which I call again in a backticks for each test
> >> script in turn, to provide a consistent starting point.
> >>
> >> In windows...  There ain't nothing in phpinfo() that matches the
> >> php.exe which I'm running...
> >>
> >> How do you handle this?
> >>
> >> Note that I'm not attempting to test specific versions of PHP --
> >> just
> >> the PHP scripts, so I really just want to run whatever PHP they are
> >> already running in their test environment, whatever that might be.
> >>
> >> It's not in $argv, it's not in ENV.
> >
> > What does $argv look like in windows?
> 
> $argv looks the same in both cases.
> 
> array (0) {
> }

Just a thought: var_dump(ini_get('register_argc_argv')) ?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Windows ENV['_'] equivalent

2006-10-16 Thread Richard Lynch
On Fri, October 13, 2006 8:14 pm, Ed Lazor wrote:
> Not a solution, but an idea...  the dos chdir comand.  Maybe you can
> run it from within your script. It tells you the current working
> directory and you end up indirectly knowing the location of the
> php.exe that you're using.

The test scripts live on a remote computer upon which I can't even run
an application like php.exe

The directory from which the other developers might choose to run the
test scripts is going to be typically idiosyncratic to their own dev
environment and drive mappings of remote shares.

I'm already pretty much forcing them to install php5 on their own
desktop/dev-box somewhere, if they don't already have it.

If they do have it, it could be anywhere.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Windows ENV['_'] equivalent

2006-10-16 Thread Richard Lynch
On Fri, October 13, 2006 7:44 pm, Roman Neuhauser wrote:
> # [EMAIL PROTECTED] / 2006-10-13 13:53:56 -0500:
>> So, I have this automated testing script I wrote, and I want to make
>> it work on more than just my computer.
>>
>> In cygwin, and in Linux, EVN['_'] has the nice path to the binary
>> CLI
>> which is running -- which I call again in a backticks for each test
>> script in turn, to provide a consistent starting point.
>>
>> In windows...  There ain't nothing in phpinfo() that matches the
>> php.exe which I'm running...
>>
>> How do you handle this?
>>
>> Note that I'm not attempting to test specific versions of PHP --
>> just
>> the PHP scripts, so I really just want to run whatever PHP they are
>> already running in their test environment, whatever that might be.
>>
>> It's not in $argv, it's not in ENV.
>
> What does $argv look like in windows?

$argv looks the same in both cases.

array (0) {
}

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Windows ENV['_'] equivalent

2006-10-16 Thread Jochem Maas
Richard Lynch wrote:
> So, I have this automated testing script I wrote, and I want to make
> it work on more than just my computer.
> 
> In cygwin, and in Linux, EVN['_'] has the nice path to the binary CLI
> which is running -- which I call again in a backticks for each test
> script in turn, to provide a consistent starting point.
> 
> In windows...  There ain't nothing in phpinfo() that matches the
> php.exe which I'm running...
> 
> How do you handle this?
> 
> Note that I'm not attempting to test specific versions of PHP -- just
> the PHP scripts, so I really just want to run whatever PHP they are
> already running in their test environment, whatever that might be.
> 
> It's not in $argv, it's not in ENV.
> 
> I've check the getmyinode() friends in PHP Options/Info page.
> 
> Surely Windows provides this info to PHP somewhere, and PHP exposes
> it, right?...  Guess not, hunh.
> 
> Anybody got a solution?

2 possible ideas:

1. use a wrapper script that allows you to specify which binary to run
the tests with. e.g. (my example suggests you would have a wrapper for
every version of php you wanted to test with)

> php5-1.bat runtests.php

php5-1.bat:
-
@echo off

:init_arg
set args=

:get_arg
shift
if "%0"=="" goto :finish_arg
set args=%args% %0
goto :get_arg
:finish_arg

set php=C:\path\to\php5.1.exe
set ini=C:\path\to\php5.1.ini
%php% -c %ini% -dPHP_VERSION=%php% %args%


2. try making use of the $_ENV['PHP_PEAR_PHP_BIN'] value which should be
configured if pear is installed properly. (it's there in my local setup


just some rough ideas, hope that one of them serves well enough to be
used as a workaround for the windows lack of functionality. good luck
(ps I'm very interested how you tackle the problem, looking forward to any
response)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Windows ENV['_'] equivalent

2006-10-14 Thread Ed Lazor


On Oct 14, 2006, at 2:09 AM, Stut wrote:

Unfortunately there's no guarantee that a) the working directory  
will be where the PHP binary is, or b) that the binary is called  
php.exe.


Richard: AFAIK there is no way to know this under windows without  
writing an extension to tell you.


-Stut


Wouldn't it be an easy task of PHP checking the results to see if  
file_exists?  That would resolve the first part, but it might  
indirectly tell you whether you're using php.exe.  If the file_exists  
fails, then you can probably assume you're using the dll.  I know...  
a hacked solution, but maybe it will work?


-Ed

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Windows ENV['_'] equivalent

2006-10-14 Thread Stut

Ed Lazor wrote:

On Oct 13, 2006, at 11:53 AM, Richard Lynch wrote:

In windows...  There ain't nothing in phpinfo() that matches the
php.exe which I'm running...

How do you handle this?


Not a solution, but an idea...  the dos chdir comand.  Maybe you can run 
it from within your script. It tells you the current working directory 
and you end up indirectly knowing the location of the php.exe that 
you're using.


Unfortunately there's no guarantee that a) the working directory will be 
where the PHP binary is, or b) that the binary is called php.exe.


Richard: AFAIK there is no way to know this under windows without 
writing an extension to tell you.


-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Windows ENV['_'] equivalent

2006-10-13 Thread Ed Lazor


On Oct 13, 2006, at 11:53 AM, Richard Lynch wrote:


So, I have this automated testing script I wrote, and I want to make
it work on more than just my computer.

In cygwin, and in Linux, EVN['_'] has the nice path to the binary CLI
which is running -- which I call again in a backticks for each test
script in turn, to provide a consistent starting point.

In windows...  There ain't nothing in phpinfo() that matches the
php.exe which I'm running...

How do you handle this?

Note that I'm not attempting to test specific versions of PHP -- just
the PHP scripts, so I really just want to run whatever PHP they are
already running in their test environment, whatever that might be.

It's not in $argv, it's not in ENV.

I've check the getmyinode() friends in PHP Options/Info page.

Surely Windows provides this info to PHP somewhere, and PHP exposes
it, right?...  Guess not, hunh.

Anybody got a solution?


Not a solution, but an idea...  the dos chdir comand.  Maybe you can  
run it from within your script. It tells you the current working  
directory and you end up indirectly knowing the location of the  
php.exe that you're using.


-Ed

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Windows ENV['_'] equivalent

2006-10-13 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-13 13:53:56 -0500:
> So, I have this automated testing script I wrote, and I want to make
> it work on more than just my computer.
> 
> In cygwin, and in Linux, EVN['_'] has the nice path to the binary CLI
> which is running -- which I call again in a backticks for each test
> script in turn, to provide a consistent starting point.
> 
> In windows...  There ain't nothing in phpinfo() that matches the
> php.exe which I'm running...
> 
> How do you handle this?
> 
> Note that I'm not attempting to test specific versions of PHP -- just
> the PHP scripts, so I really just want to run whatever PHP they are
> already running in their test environment, whatever that might be.
> 
> It's not in $argv, it's not in ENV.

What does $argv look like in windows?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Windows ENV['_'] equivalent

2006-10-13 Thread Richard Lynch
So, I have this automated testing script I wrote, and I want to make
it work on more than just my computer.

In cygwin, and in Linux, EVN['_'] has the nice path to the binary CLI
which is running -- which I call again in a backticks for each test
script in turn, to provide a consistent starting point.

In windows...  There ain't nothing in phpinfo() that matches the
php.exe which I'm running...

How do you handle this?

Note that I'm not attempting to test specific versions of PHP -- just
the PHP scripts, so I really just want to run whatever PHP they are
already running in their test environment, whatever that might be.

It's not in $argv, it's not in ENV.

I've check the getmyinode() friends in PHP Options/Info page.

Surely Windows provides this info to PHP somewhere, and PHP exposes
it, right?...  Guess not, hunh.

Anybody got a solution?

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php