Is there a way to determine the path to the php executable (as opposed
to the script. In other words, I am looking for the path to php.exe or
php-win.exe) that is currently running (ie. how was this script called)
on Windows (I'm on Win XP Pro)? WScript/CScript (when programming in
VBScript) allow this, for example.
Failing that, is there any way to conclusively determine whether the
script that is running was invoked from php.exe or php-win.exe? I say
conclusively, because often there is a slight difference in the
environment variables, but it need not be the case.
Thanks,
Csaba Gabor from New York 17 2652
Csaba Gabor wrote:
Is there a way to determine the path to the php executable (as opposed
to the script. In other words, I am looking for the path to php.exe or
php-win.exe) that is currently running (ie. how was this script called)
on Windows (I'm on Win XP Pro)? WScript/CScript (when programming in
VBScript) allow this, for example.
Failing that, is there any way to conclusively determine whether the
script that is running was invoked from php.exe or php-win.exe? I say
conclusively, because often there is a slight difference in the
environment variables, but it need not be the case.
Thanks,
Csaba Gabor from New York
Running phpinfo() should tell you if its running as a module or cgi. I
believe it also has path information. It is probably in at least one
of the directories of the path variables. Barring all that, you could
search the file system with a script or exec() call
Richard Levasseur wrote:
Csaba Gabor wrote:
Is there a way to determine the path to the php executable (as opposed
to the script. In other words, I am looking for the path to php.exe or
php-win.exe) that is currently running (ie. how was this script called)
on Windows (I'm on Win XP Pro)? WScript/CScript (when programming in
VBScript) allow this, for example.
Failing that, is there any way to conclusively determine whether the
script that is running was invoked from php.exe or php-win.exe? I say
conclusively, because often there is a slight difference in the
environment variables, but it need not be the case.
Thanks for your response:
Running phpinfo() should tell you if its running as a module or cgi.
Yes. And easier is php_sapi_name() [or PHP_SAPI], which produces
apache2handler when I'm running php as a web server module. But it
shows me the same thing when php is started from the command line with
either php.exe vs. php-win.exe: cli. If I try try the same thing with
php-cgi, then I get: cgi-fcgi
So that's why the remaining problem is differentiating between php.exe
vs. php-win.exe
I believe it also has path information.
phpinfo() shows the PATH environment variable. It does not show the
path to the executable, nor does it show the executable name.
It is probably in at least one
of the directories of the path variables.
I agree that it probably is. But even under that assumption, how do
you programatically differentiate between php.exe vs. php-win.exe?
Barring all that, you could search the file system with a script or exec() call
Could you elaborate, please - How does this let me determine the called
executable?
Csaba
Csaba Gabor wrote:
Is there a way to determine the path to the php executable (as opposed
to the script. In other words, I am looking for the path to php.exe or
php-win.exe) that is currently running (ie. how was this script called)
on Windows (I'm on Win XP Pro)? WScript/CScript (when programming in
VBScript) allow this, for example.
As far as I know there is no way, unless you load in a COM object.
Failing that, is there any way to conclusively determine whether the
script that is running was invoked from php.exe or php-win.exe? I say
conclusively, because often there is a slight difference in the
environment variables, but it need not be the case.
No, the only difference between php.exe and php-win.exe is whether a
console window opens or not and you can't detect that programmaticall y.
Chung Leong wrote:
Csaba Gabor wrote:
Is there a way to determine the path to the php executable (as opposed
to the script. In other words, I am looking for the path to php.exe or
php-win.exe) that is currently running (ie. how was this script called)
on Windows (I'm on Win XP Pro)? WScript/CScript (when programming in
VBScript) allow this, for example.
As far as I know there is no way, unless you load in a COM object.
Loading in a COM object is fine by me, but would you clarify your
remark, please, as to which one to load and how to use it. Or are you
talking about a 3rd party COM object that one must purchase?
Failing that, is there any way to conclusively determine whether the
script that is running was invoked from php.exe or php-win.exe? I say
conclusively, because often there is a slight difference in the
environment variables, but it need not be the case.
No, the only difference between php.exe and php-win.exe is whether a
console window opens or not and you can't detect that programmaticall y.
Hmm, I'm just wondering about the relationship between the console
window (if it opens) and php. At any rate, thanks for your comments.
Csaba Gabor wrote:
Loading in a COM object is fine by me, but would you clarify your
remark, please, as to which one to load and how to use it. Or are you
talking about a 3rd party COM object that one must purchase?
I had the Wscript.Shell object in mind. I think you can initialize it
in PHP.
Csaba Gabor wrote:
Richard Levasseur wrote:
Csaba Gabor wrote:
Is there a way to determine the path to the php executable (as opposed
to the script. In other words, I am looking for the path to php.exe or
php-win.exe) that is currently running (ie. how was this script called)
on Windows (I'm on Win XP Pro)? WScript/CScript (when programming in
VBScript) allow this, for example.
>
Failing that, is there any way to conclusively determine whether the
script that is running was invoked from php.exe or php-win.exe? I say
conclusively, because often there is a slight difference in the
environment variables, but it need not be the case.
Thanks for your response:
Running phpinfo() should tell you if its running as a module or cgi.
Yes. And easier is php_sapi_name() [or PHP_SAPI], which produces
apache2handler when I'm running php as a web server module. But it
shows me the same thing when php is started from the command line with
either php.exe vs. php-win.exe: cli. If I try try the same thing with
php-cgi, then I get: cgi-fcgi
So that's why the remaining problem is differentiating between php.exe
vs. php-win.exe
I believe it also has path information.
phpinfo() shows the PATH environment variable. It does not show the
path to the executable, nor does it show the executable name.
It is probably in at least one
of the directories of the path variables.
I agree that it probably is. But even under that assumption, how do
you programatically differentiate between php.exe vs. php-win.exe?
Barring all that, you could search the file system with a script or exec() call
Could you elaborate, please - How does this let me determine the called
executable?
Csaba
Sorry, I overlooked the part about php.exe and php-win.exe.
But why does it matter if its using the nix or the windows php
executable? IIRC, php can be invoked using php.exe on both windows and
*nix. Unless there is some very specific reason I don't know about?
If you're worried about differences between environment variables
because of the host OS, then check the OS environment variables and act
accordingly. If you see a X:\ in any of the paths, you can also know
if its windows or nix. same for the include_path directive (unix uses
:, windows uses ;).
Richard Levasseur wrote:
Csaba Gabor wrote:
Richard Levasseur wrote:
Csaba Gabor wrote:
Is there a way to determine the path to the php executable (as opposed
to the script. In other words, I am looking for the path to php.exe or
php-win.exe) that is currently running (ie. how was this script called)
on Windows (I'm on Win XP Pro)? WScript/CScript (when programming in
VBScript) allow this, for example.
Failing that, is there any way to conclusively determine whether the
script that is running was invoked from php.exe or php-win.exe? I say
conclusively, because often there is a slight difference in the
environment variables, but it need not be the case.
Thanks for your response:
Running phpinfo() should tell you if its running as a module or cgi.
Yes. And easier is php_sapi_name() [or PHP_SAPI], which produces
apache2handler when I'm running php as a web server module. But it
shows me the same thing when php is started from the command line with
either php.exe vs. php-win.exe: cli. If I try try the same thing with
php-cgi, then I get: cgi-fcgi
So that's why the remaining problem is differentiating between php.exe
vs. php-win.exe
I believe it also has path information.
Sorry, I overlooked the part about php.exe and php-win.exe.
But why does it matter if its using the nix or the windows php
executable? IIRC, php can be invoked using php.exe on both windows and
*nix. Unless there is some very specific reason I don't know about?
I'm not concerned about *nix.
If you invoke php.exe and then do a print "whatever";
then you will get whatever output to the console window.
However, if you invoke php-win.exe and then do a print "whatever";
then you won't get anything since there is no console window. In other
words, while print might be sufficient with php.exe, it definitely
isn't with php-win.exe. Therefore, it makes sense to be able to
differentiate between them for some circumstances (so that an
alternative to print can be performed).
Csaba
Note: you could, of course, capture the output in both scenarios via
ob_start() and friends, but that is not the point.
If you're worried about differences between environment variables
because of the host OS, then check the OS environment variables and act
accordingly. If you see a X:\ in any of the paths, you can also know
if its windows or nix. same for the include_path directive (unix uses
:, windows uses ;).
Csaba Gabor wrote:
Richard Levasseur wrote:
Csaba Gabor wrote:
Richard Levasseur wrote:
Csaba Gabor wrote:
Is there a way to determine the path to the php executable (as opposed
to the script. In other words, I am looking for the path to php.exe or
php-win.exe) that is currently running (ie. how was this script called)
on Windows (I'm on Win XP Pro)? WScript/CScript (when programming in
VBScript) allow this, for example.
>
Failing that, is there any way to conclusively determine whether the
script that is running was invoked from php.exe or php-win.exe? I say
conclusively, because often there is a slight difference in the
environment variables, but it need not be the case.
>
Thanks for your response:
>
Running phpinfo() should tell you if its running as a module or cgi.
>
Yes. And easier is php_sapi_name() [or PHP_SAPI], which produces
apache2handler when I'm running php as a web server module. But it
shows me the same thing when php is started from the command line with
either php.exe vs. php-win.exe: cli. If I try try the same thing with
php-cgi, then I get: cgi-fcgi
>
So that's why the remaining problem is differentiating between php.exe
vs. php-win.exe
>
I believe it also has path information.
Sorry, I overlooked the part about php.exe and php-win.exe.
But why does it matter if its using the nix or the windows php
executable? IIRC, php can be invoked using php.exe on both windows and
*nix. Unless there is some very specific reason I don't know about?
I'm not concerned about *nix.
If you invoke php.exe and then do a print "whatever";
then you will get whatever output to the console window.
However, if you invoke php-win.exe and then do a print "whatever";
then you won't get anything since there is no console window. In other
words, while print might be sufficient with php.exe, it definitely
isn't with php-win.exe. Therefore, it makes sense to be able to
differentiate between them for some circumstances (so that an
alternative to print can be performed).
Csaba
Note: you could, of course, capture the output in both scenarios via
ob_start() and friends, but that is not the point.
If its being executed directly through one of the exe's, the
executable's name should be in argv[0]. That would let you get the
exe's real name. Not sure how true this is if its executed via the
webserver, though. I think the web server populates argv with get
parameters or something. If its being executed via the webserver, you
can probably assume print will work as intended.
I'm wondering what your final intent is? If you have a console window,
make html, otherwise make GUI widgets?
If you're worried about differences between environment variables
because of the host OS, then check the OS environment variables and act
accordingly. If you see a X:\ in any of the paths, you can also know
if its windows or nix. same for the include_path directive (unix uses
:, windows uses ;).
Richard Levasseur wrote:
Csaba Gabor wrote:
Richard Levasseur wrote:
Csaba Gabor wrote:
Richard Levasseur wrote:
Csaba Gabor wrote:
Is there a way to determine the path to the php executable (as opposed
to the script. In other words, I am looking for the path to php.exe or
php-win.exe) that is currently running (ie. how was this script called)
on Windows (I'm on Win XP Pro)? WScript/CScript (when programming in
VBScript) allow this, for example.
Failing that, is there any way to conclusively determine whether the
script that is running was invoked from php.exe or php-win.exe? I say
conclusively, because often there is a slight difference in the
environment variables, but it need not be the case.
Thanks for your response:
Running phpinfo() should tell you if its running as a module or cgi.
Yes. And easier is php_sapi_name() [or PHP_SAPI], which produces
apache2handler when I'm running php as a web server module. But it
shows me the same thing when php is started from the command line with
either php.exe vs. php-win.exe: cli. If I try try the same thing with
php-cgi, then I get: cgi-fcgi
So that's why the remaining problem is differentiating between php.exe
vs. php-win.exe
I believe it also has path information.
>
Sorry, I overlooked the part about php.exe and php-win.exe.
>
But why does it matter if its using the nix or the windows php
executable? IIRC, php can be invoked using php.exe on both windows and
*nix. Unless there is some very specific reason I don't know about?
I'm not concerned about *nix.
If you invoke php.exe and then do a print "whatever";
then you will get whatever output to the console window.
However, if you invoke php-win.exe and then do a print "whatever";
then you won't get anything since there is no console window. In other
words, while print might be sufficient with php.exe, it definitely
isn't with php-win.exe. Therefore, it makes sense to be able to
differentiate between them for some circumstances (so that an
alternative to print can be performed).
Csaba
Note: you could, of course, capture the output in both scenarios via
ob_start() and friends, but that is not the point.
If its being executed directly through one of the exe's, the
executable's name should be in argv[0]. That would let you get the
exe's real name.
I presume you are talking about WScript/CScript here because this
doesn't work with PHP. If you have delme.php:
<?php print 'argv[0]: ' . $GLOBALS["argv"][0]; ?>
and do:
php.exe delme.php
then you will get:
argv[0]: delme.php
Not sure how true this is if its executed via the
webserver, though. I think the web server populates argv with get
parameters or something. If its being executed via the webserver, you
can probably assume print will work as intended.
I'm wondering what your final intent is? If you have a console window,
make html, otherwise make GUI widgets?
Yes, I am doing CLI PHP applets. Now if I have php.exe in a console, I
can safely do print, knowing that the user has a fighting chance of
seeing it. However, if the script is invoked via php-win.exe (by
double clicking on it for explorer, for example), then doing a print
ensures that the user will never see the output (which is probably
undesireable in most situations).
The point is that it makes good sense to differentiate between the two
if I don't want to uniformly throw up a popup or other GUI. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: MT |
last post by:
Hello Everyone:
I am running XP Pro with IIS 5.1.
Which is the best PHP version to install:
CGI, CLI or ISAPI??
The installation manual lists all three but does
not say which is most stable, fastest, other
advantages/disadvantage.
|
by: Dave |
last post by:
Hi
I have been asked to implement an error logging/management database for the
network technicians in our company. The idea is that staff using
workstations can enter a database and log any problems they are having,
while the technicians can pull off details of faulty equipment. The users
will have little experience of databases so the system needs to be
customized to allow users access to facilities via simple a gui. The network
is ...
|
by: Jeff Rodriguez |
last post by:
Here's what I want do:
Have a main daemon which starts up several threads in a Boss-Queue structure.
From those threads, I want them all to sit and watch a queue. Once an entry
goes into the queue, grab it and run a system command.
Now I want to make sure that system command doesn't hang forever, so I need some
way to kill the command and have the worker thread go back to work waiting for
another queue entry.
|
by: Pujo Aji |
last post by:
Hello,
I use ManualResetEvent to stop and allow a thread running by setting:
public static ManualResetEvent mre = new ManualResetEvent(false);
So if I use mre.WaitOne(); this let the thread stop
and I can use mre.Set to let the thread do it's process.
The problem is can I use this kind of mechanism to choose which thread
should run, for example I have two threads which in their inside code
|
by: Phil Mc |
last post by:
Say for example you have a application running on a windows 2003 server
(that is on server, not from). This application needs to start child
applications (must be stand alone console applications), but these
child applications must have the same security privileges as the parent
starting them.
I have created a scheduling app (which will be started by autosys job),
which must start child apps when certain criteria are met. The
scheduling...
| |
by: Michael Malinowski |
last post by:
Is there a way to read the directory that the currently running python file
is located in?
Cheers
Mike.
|
by: Phil Stanton |
last post by:
I have a number of queries which use code for the output of 1 or more
fields. For example
Address:GetAddress(AddressID, True, 60)
Address ID Points to an Address in a table - Address Line1, Line 2, Line 3,
Town, County, Post Code, Country.
The True is whether to include the country and the 60 is the maximum line
length (after which a line feed is inserted). All this is to output to a
formatted RTF file for a handbook.
In addition, I...
|
by: pamela fluente |
last post by:
I have an application running. A file type is registered with this
application. When the user click on a file of such type a new instance
of the application is loaded with command line (file name).
I want to shut done this new instance an to notify the instance which
is already running, by passing the command line to it (so that the
file can be open by the application already runnning).
Here is my code, how do I notify the running...
|
by: Patient Guy |
last post by:
Which is the better approach in working with Javascript?
1. Server side processing: Web server gets form input, runs it into the
Javascript module, and PHP collects the output for document prep.
2. Client side processing: Web server gets form input and passes it to PHP
which includes the Javascript written in a way to make the form input
processed on the client side and rendered (probably using DOM function
calls) on that side as...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |