Executing PHP code from the command line<

windows

Guest
Is there any way to run a chunk of PHP code (to alter my SQL database) from the command line? Like, maybe by using an .exe with some parameters or something.exec() could do the trick for ya:

<!-- m --><a class="postlink" href="http://www.php.net/manual/en/function.exec.phpIm">http://www.php.net/manual/en/function.exec.phpIm</a><!-- m --> developing a piece of perl code which access a database, so I just run the perl code form the command line.

perl nameoffile.pl

(once perl is installed)It seems as though exec() is the exact inverse of what I'm trying to do. I don't want to run a command line from PHP. I want to run PHP from a command line.you would still use exec() to do it. or you can try system()Hrm... Well, I found this page:
<!-- m --><a class="postlink" href="http://www.php.net/features.commandline">http://www.php.net/features.commandline</a><!-- m -->
And it kinda spells it out for me. This is what I was looking for:

php.exe -f C:\swamp\www\storage\ffxi\manage\deleteblank.php

When I run that line from a command prompt it executes the php code found in deleteblank.php... I still don't see how I'd use exec()...

Thanks anywaythe commandline you can do just about anyhting, you just do get the output like in a browser

and generally you don't run a php file from the comandline, you usually run the php code from it, raw code that is. if you ahve the file why not run it from the browser, unless you don't have a server installed like apache.
 
Back
Top