Hi,

It is possible to execute a php script from the command line in UNIX or Linux by specifying the path to the php executable such as:
#!/path/to/php
<?
//blocks of script
?>

I have not been able to figure out a way to make this work on Windows. Has anyone had any success running php from the command line in Windows, or knows how I could do this?

Thanks,

David

    one very basic question...(I'm posting this one here coz methinks I have a simlar problem)

    Do we need to make any changes(more) in the php.ini file for the phpGTK apps. to run properly ?? This is assuming i have the other php (web) version running very successfully on my system.
    But I got too hard luck with this GTK thing

      I just got myself phpGTK+
      Looks like I have followed all instructions in installing it...but when I try to open the test/hello.php application, it says php.exe not found 🙁

      Here's wht I did..

      unzipped my php-gtk-0.5.1-win32.zip files into my existing php directory at c:/php. then like mentioned in the manual, I copied the files from c:/php/winnt/system32 files into my own system32 files (located at d:/windows/system32); then the php.ini file...I already had one in the d:/windows dir but then I copied the new one over the old one, and pade these changes in it...

      doc_root = "E:\" ; the root Web
      extension_dir = "E:\"

      and phew!!! copied the test folder into E:\ which is whr all my php files always reside.
      Then....emmm...I opened command prompt and happily typed in c:/php/php4/php -q yo....that thing made php start running in the window.
      Now, when I tried running hello.php it juss doesn't open up. I tried open with>> md dos prompt, it resulted in opening a command prompt and no more than that. Then...I said open with>>php.exe...this time it opened a command prompt and quickly displayed all src code and vanished. finally I said open with >>php_win.exe, and what I got in return was an err message saying php.exe was not found.

      I'm completely confused. Aparently thrs nothing wrong with the php.ini file becoz all my other php files are running just fine (the web files)...suggestions anyone ????

        c:\install\dir\of\php\sapi\php.exe myPhpScript.php

          almost looks like THE solution....but methinks I need some help deciphering it....what does it really mean ???

            You shouldn't need to put C:\path\to\php (never put .exe on the end!)
            <?php
            yadadaaadadadad
            ?>
            Just <?php
            //blocks
            ?>
            and run it from the command line using
            php C:\path\to\file.php

            That is if the path to php.exe is in your path . . .

              what if its entirely in a different path like mine, the fact that I have configured that in my php.ini wont that make it work....aparently it isn't quite making it work 😃

                Maybe I'm missing something here but if you put php.exe on say the E:\ drive and all of your stuff is on say the F:\ drive, Windows will still search through the path no matter where you are.

                  Write a Reply...