|
-
Apr 1st, 2009, 03:28 AM
#1
Thread Starter
Hyperactive Member
Php cli
I want to be able to run php scripts from the command line in Vista. Can someone please give me the setx code I need to get it to work?
Thanks
I tried: setx php "C:\the\path\to\php.exe"
It didnt work.
-
Apr 1st, 2009, 04:54 AM
#2
Re: Php cli
well, the "setx" command sets an environment variable, it doesn't run anything. I don't know why you'd be trying to use it to run a script.
to run something with PHP, you just need to point the PHP executable to your script. this should run script.php:
Code:
E:\root\php5\php.exe E:\root\www\script.php
you can read more about using PHP from the command line with arguments and options here on php.net
Last edited by kows; Apr 1st, 2009 at 04:58 AM.
-
Apr 1st, 2009, 02:01 PM
#3
Thread Starter
Hyperactive Member
Re: Php cli
Thats wack, cant I have the php command work like the java command?
Isn't that what a environment variable is for?
-
Apr 1st, 2009, 02:44 PM
#4
Re: Php cli
huh? you don't need an environment variable to run java either. I think you're getting things very mixed up.
environment variables are variables stored for the system. they aren't required for anything you're doing. variables provide shortcuts; they do not run programs.
if you wanted a shorthand way to run php files (without needing to provide the full path of PHP), you could append the environment variable "path" with the path to PHP's installed directory. this will let you run "php.exe" without needing to be in PHP's native directory.
Code:
set path=%path%;E:\root\php5
then, you could run this:
Code:
php E:\root\www\script.php
if you'd like to permanently add that path to the "path" variable, then you'll need to change the environment variables. in windows explorer, type in the path, "Control Panel\System and Maintenance\System", then click on "Change Settings." you'll need to confirm with UAC if you have it on. go to the "Advanced" tab, then to "Environment Variables" at the bottom. under "System Variables," there will be one named "Path." you can simply append ";E:\root\php5" to it, not forgetting to add the semi-colon. and don't get rid of any of the information inside of that variable already.
-
Apr 2nd, 2009, 06:00 PM
#5
Thread Starter
Hyperactive Member
Re: Php cli
Code:
set path=%path%;E:\root\php5
was exactly what I was looking for. Thanks guy.
-
Apr 7th, 2009, 01:00 AM
#6
Thread Starter
Hyperactive Member
Re: Php cli
Code:
set path=%path%;E:\root\php5
This works but when I reboot it no longer works. How do I make it stick?
-
Apr 7th, 2009, 01:04 AM
#7
Re: Php cli
read the last paragraph of my last post in this thread.
-
Apr 8th, 2009, 01:27 AM
#8
Thread Starter
Hyperactive Member
Re: Php cli
woops, missed it. Got to excited about set path=%path%;E:\root\php5. It works, thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|