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
https://forums.phpfreaks.com/topic/55442-php-executable-path/#findComment-274251
Share on other sites

okay, heres what i need to ge done exactly. I have a PHP script that i need to execute from the command line. This script is executed by another script.

 

Script A executes script B using exec(path/to/php -f scriptb.php);

 

 

I need to know path to PHP right?

 

Link to comment
https://forums.phpfreaks.com/topic/55442-php-executable-path/#findComment-274355
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
https://forums.phpfreaks.com/topic/55442-php-executable-path/#findComment-274366
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
https://forums.phpfreaks.com/topic/55442-php-executable-path/#findComment-274400
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.