Execute php script in a bat file: Difference between revisions

Jump to navigation Jump to search
Line 33: Line 33:
Options "-f <file>        Parse and execute <file>."<ref>[http://php.net/manual/en/features.commandline.options.php PHP: Options - Manual]</ref>
Options "-f <file>        Parse and execute <file>."<ref>[http://php.net/manual/en/features.commandline.options.php PHP: Options - Manual]</ref>


== Example bat file ==
== Example of bat file ==
Condition 1: The DOS window was NOT closed automatically when PHP script which implemented [http://php.net/manual/en/function.exit.php exit()] and return error code 1.
Condition 1: The DOS window was NOT closed automatically when PHP script which implemented [http://php.net/manual/en/function.exit.php exit()] and return error code 1.
<pre>
<pre>
Line 50: Line 50:
c:\path\to\php.exe "c:\path\to\php_script2.php" -var2=value2
c:\path\to\php.exe "c:\path\to\php_script2.php" -var2=value2
PAUSE
PAUSE
</pre>
== Example of bash file ==
The BASH window was NOT closed automatically when PHP script which implemented [http://php.net/manual/en/function.exit.php exit()] and return error code 1.
<pre>
#!/bin/bash
path/to/php "path/to/php_script.php" -var1=value1
if [ $? -eq 1 ]; then
  read -n 1 -s -r -p "Press any key to continue"
  exit 1
fi
</pre>
</pre>


Navigation menu