EXiT Posted April 11, 2008 Share Posted April 11, 2008 I'm trying to open a .php file in the cmd.The location of the file is c:\Apache2\Apache2\htdocs\test.php In this book im reading it says, it should run in the cmd window but when i type in cd \Apache2\Apache2\htdocs\test.php, it opens the file in a text editor. So, how do i get this to run in the command prompt? Cheers Link to comment https://forums.phpfreaks.com/topic/100701-opening-a-php-file-in-the-command-prompt/ Share on other sites More sharing options...
p2grace Posted April 11, 2008 Share Posted April 11, 2008 The linux command is typing php in front of the file location, I'm not sure if it that works in windows or not but you can give it a try. Link to comment https://forums.phpfreaks.com/topic/100701-opening-a-php-file-in-the-command-prompt/#findComment-515013 Share on other sites More sharing options...
craygo Posted April 11, 2008 Share Posted April 11, 2008 what you have to do is run php then the file I use a bat file for one of mine cd c:\php php path/to/script.php So you have to run the php executable with a parameter pointing to the file Ray Link to comment https://forums.phpfreaks.com/topic/100701-opening-a-php-file-in-the-command-prompt/#findComment-515017 Share on other sites More sharing options...
EXiT Posted April 11, 2008 Author Share Posted April 11, 2008 Thanks for helping! Ok, i opened a new cmd and typed in: cd \php5 Now it says C:\php5> I then typed in: php Apache2\Apache2\htdocs\test.php And i get this - Could not open input file: Apache2\Apache2\htdocs\test.php Link to comment https://forums.phpfreaks.com/topic/100701-opening-a-php-file-in-the-command-prompt/#findComment-515028 Share on other sites More sharing options...
EXiT Posted April 11, 2008 Author Share Posted April 11, 2008 Here is a bit of the book: Windows allows you to set up filename associations such that a program can be associated with filenames that end with a particular suffix. This means that you can set up associations so that Perl, Ruby, PHP, or Python are used to execute files with names that end in .pl, .rb, .php, or .py, respectively. It doesn't show you how to do this though. I'm lost :'( Link to comment https://forums.phpfreaks.com/topic/100701-opening-a-php-file-in-the-command-prompt/#findComment-515033 Share on other sites More sharing options...
p2grace Posted April 11, 2008 Share Posted April 11, 2008 Try php.exe and then the location. http://www.phpit.net/article/php-on-command-line/ Link to comment https://forums.phpfreaks.com/topic/100701-opening-a-php-file-in-the-command-prompt/#findComment-515037 Share on other sites More sharing options...
craygo Posted April 11, 2008 Share Posted April 11, 2008 you will have to use an absolute path like windows i use cd c:\php php c:\hlstats\gungame\ggwins.php The problem is Apache2\Apache2\htdocs\test.php doesn't exist from your php path Ray Link to comment https://forums.phpfreaks.com/topic/100701-opening-a-php-file-in-the-command-prompt/#findComment-515046 Share on other sites More sharing options...
EXiT Posted April 11, 2008 Author Share Posted April 11, 2008 Yay! It works. Thanks Link to comment https://forums.phpfreaks.com/topic/100701-opening-a-php-file-in-the-command-prompt/#findComment-515052 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.