Monday, February 28, 2011

how to get php run on a windows shell ?


>Is there a way to execute PL/SQL scripts from PHP? I have PL/SQL scripts
>that utilizes the DBMS_xxx packages. Is it possible to shell out a command
>that will run the PL/SQL? You'll have to define what you mean by 'PL/SQL script'.

Do you mean a PL/SQL block? Just use OCIParse/OCIExecute. There's an example
in the PHP manual.

Or do you mean you have a file containing one or more SQL and/or anonymous
PL/SQL blocks, which you'd normally run with SQL*Plus? And in particular, does
it use any SQL*Plus commands? (e.g. SET, or COLUMN). If so, shell out to
SQL*Plus with system() or exec() or backticks etc.
46. how to get php run on a windows shell
As well as running PHP scripts via a web server such as Apache, you can also run PHP scripts from the command line (it's also possible to write GUI apps with PHP using PHP-GTK, but I'll maybe look at that another time). This post looks at the two ways you can run a PHP script from a *nix based computer (Linux, UNIX, BSD, OSX) and the single way you can do it from Windows.
UNIX shell scripts are set as executable and the first line in the file contains a "shebang" line which shows the path to the executable which will parse the script.
If your distro's PHP binary is at e.g. /usr/bin/php you would add this to the first line of your script:
#!/usr/bin/php
and then have your PHP script under it.
To run a "hello world script" you'd do this:
#!/usr/bin/php
  echo "hello world\n";
The script then needs to be marked as executable. To set it so it can be run as anyone do this:
chmod 0755 /path/to/script.php
To make it so only you can run it (and so no one else can even read it) do this:
chmod 0700 /path/to/script.php
Read the chmod manpage for more details about file permissions if you don't know about them

No comments:

Post a Comment