note 81543 added to function.exec
| From: | jimdotfilteratgmaildotcom at osu1 dot php dot net | Date: | Mon, 03 Mar 2008 14:45:20 +0000 |
| Subject: | note 81543 added to function.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136694@lists.php.net to get a copy of this message | ||
You can embed php into a batch file so that it is essentially "double-click" to run. This
might be useful for script that does search and replace in numerous files or other tedious task that
are too complex for batch files but don't warrant greater attention. Its really quite simple
I'm sure someone has thought of it before. You can add whatever batch code you want after
:START just make sure you exit before you get to */ so Windows doesn't fuss. @php %0 basically
is saying "Open this file with php and run its php code". Obviously its really only a
useful trick on Windows, I only really use it for update scripts on our company's servers. I
suppose you could also just set Windows to open php files with php.exe but that seems like a rather
stupid thing to do as you would most often want to edit php files, not run them directly. @pause is
optional of course, but you may want to look at what php outputted to the command line before it
exits.
example.bat:
@GOTO START
<?php
...php code...
/*
:START
...batch code...
@php %0
@pause
@exit
*/
?>
----
Server IP: 69.147.83.197
Probable Submitter: 216.135.43.146
----
Manual Page -- http://www.php.net/manual/en/function.exec.php
Edit -- https://master.php.net/note/edit/81543
Del: integrated -- https://master.php.net/note/delete/81543/integrated
Del: useless -- https://master.php.net/note/delete/81543/useless
Del: bad code -- https://master.php.net/note/delete/81543/bad+code
Del: spam -- https://master.php.net/note/delete/81543/spam
Del: non-english -- https://master.php.net/note/delete/81543/non-english
Del: in docs -- https://master.php.net/note/delete/81543/in+docs
Del: other reasons-- https://master.php.net/note/delete/81543
Reject -- https://master.php.net/note/reject/81543
Search -- https://master.php.net/manage/user-notes.php