Execute php script in a bat file: Difference between revisions

Jump to navigation Jump to search
Line 40: Line 40:


== Troubleshootings ==
== Troubleshootings ==
=== Error: The system cannot find the path specified. ===
<pre>
c:\path\to\php.exe -f "c:\path\to\php_script.php"
</pre>
Possible solutions: Check the php path if correct or not
<pre>
dir c:\path\to\php.exe
</pre>
=== Error: Could not open input file ===
Error message<ref>[https://stackoverflow.com/questions/29435912/how-do-i-pass-parameters-to-a-php-script-in-a-bat-file windows - How do I pass parameters to a php script in a bat file - Stack Overflow]</ref>: Could not open input file
Error message<ref>[https://stackoverflow.com/questions/29435912/how-do-i-pass-parameters-to-a-php-script-in-a-bat-file windows - How do I pass parameters to a php script in a bat file - Stack Overflow]</ref>: Could not open input file


Line 47: Line 58:
</pre>
</pre>


Solution: (1) add {{kbd | key=<nowiki>--</nowiki>}} after php script (2) remove {{kbd|key=<nowiki>-f</nowiki>}} option from command
Possible solutions: (1) add {{kbd | key=<nowiki>--</nowiki>}} after php script (2) remove {{kbd|key=<nowiki>-f</nowiki>}} option from command
<pre>
<pre>
c:\path\to\php.exe -f "c:\path\to\php_script.php" -- -var1=value1
c:\path\to\php.exe -f "c:\path\to\php_script.php" -- -var1=value1
Line 54: Line 65:


c:\path\to\php.exe "c:\path\to\php_script.php" -var1=value1
c:\path\to\php.exe "c:\path\to\php_script.php" -var1=value1
</pre>
(3) Enclose the whole path with double quote symbols
<pre>
Wrong: c:\path\to\php.exe c:\path\contain white space\php_script.php
Correct: c:\path\to\php.exe "c:\path\contain white space\php_script.php"
</pre>
</pre>


Navigation menu