Jump to content

php executable path


mridang_agarwal

Recommended Posts

Is there a common solution both Windows and Unix systems?

 

Nope. Windows isn't terribly scriptable by default. I'm not even sure it comes with a default scripting language.. Maybe vbscript? but as far as I know windows also does not have any utilities for detecting where executables are located within a user PATH.

 

Explain exactly what it is your trying to do. A shebang line is probably all your looking for, but then again, I don't think these effect windows.

Link to comment
Share on other sites

I need to know path to PHP right?

 

If your creating command line scripts they should have a shabang as there first line. eg;

 

#!/usr/bin/php

 

This tells the shell how to execute the program (Linux). I could almost guarantee that that will be the location of php on all Linux installs. If not, it will at least link to the actual executable.

 

As for windows, sorry, but I have no idea. You could probably try searching the user PATH variable (which I'de assume you can get through $_ENV['PATH']), but it wont be pretty.

 

You say your calling your script via exec(path/to/php -f scriptb.php), if this is happening from within a php script why not simply use include()?

Link to comment
Share on other sites

i want my script to run as a daemon so i decided to make it run from the command line.

 

Sorry, what comment are you referring to? Is this an excuse for not using include(). If so, it makes no sense. You only need to call the initiating script form the command line.

Link to comment
Share on other sites

if it doesnt work ask your host.

 

You keep saying 'ask your host'. How do you know the OP is not trying to develop a deployable application?

[i've provided him alternatives also]

Hosting Companies server is set up in such a way that you have permission to do a very few things in shell and with that you cant do any deployable application.

But I think they should tell him.

else

rely upon PHP CLI

php -f yourscript.php

Cause we dont know where is the php

is it in bin or sbin

-----------------------------------------------------

See your PATH

it would be like

PATH 	/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Check with all of this 1 By 1

e.g.

/usr/local/sbin/php

/usr/local/bin/php

/usr/sbin/php

Bla Bla ......

Else

-----------------------------------

Can you read your .profile if yes get the value of PATH from it

and check in teh Previous way

else

-----------------------------------------

Make a shell script and in it try using

php -f yourscript.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.