run from command line

Problems with the Windows version of XAMPP, questions, comments, and anything related.

run from command line

Postby hobbyist » 30. October 2009 14:35

I'm new to xampp, php, and stuff so forgive me for a simple question. I couldn't find it addressed in the search command. How do you run a php file from the shell or command line? I have a test.php in the htdocs folder that runs properly when using internet explorer so I know it works. Also where can I learn the commands for the shell?
hobbyist
 
Posts: 5
Joined: 30. October 2009 14:17

Re: run from command line

Postby IamJim » 30. October 2009 14:53

Been a few weeks for me,
but I think

php test.php

Should work if your paths are correct

Jim
IamJim
 
Posts: 56
Joined: 27. April 2009 03:01

Re: run from command line

Postby Izzy » 30. October 2009 22:46

hobbyist wrote:...where can I learn the commands for the shell?
Use the Shell button in your XAMPP Control Panel then at the prompt # type:
php -h
will give a list of commands with some comments.
Code: Select all
Usage: php [options] [-f] <file> [--] [args...]
       php [options] -r <code> [--] [args...]
       php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
       php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
       php [options] -- [args...]
       php [options] -a

So to parse your file, the -f is optional:
php -f htdocs\test.php
or
php htdocs\test.php

More examples:
php -f htdocs\xampp\phpinfo.php
1 page at a time:
php -f htdocs\xampp\phpinfo.php |more
Use the shift plus \ keys to get the pipe |

The php web site may have much more info:
http://us3.php.net/results.php?q=command+line&l=en&p=all

For a list of Shell (DOS) commands at the prompt # type:
help

For help with a specific command type help followed by the command, for example:
help MORE


If this topic needs to be kept alive, then if those with more knowledge on this subject would be so kind as to add more detail so that it may help others searching the forum for this subject.
Thanks.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: run from command line

Postby hobbyist » 31. October 2009 02:57

I appreciate the input. When I type those commands i get

"c:\xampp\php.exe is not a valid Win32 application"

the command line then says "Access is denied."
hobbyist
 
Posts: 5
Joined: 30. October 2009 14:17

Re: run from command line

Postby Izzy » 31. October 2009 03:48

hobbyist wrote:When I type those commands
Where are you trying to type those command?

What Windows OS?

Which version of XAMPP?
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: run from command line

Postby hobbyist » 02. November 2009 03:20

Izzy wrote:Where are you trying to type those command?


I'm typing the commands on the XAMPP for windows screen that shows up when I hit "shell" command from the XAMPP control panel

Izzy wrote:What Windows OS?


window xp

Izzy wrote:Which version of XAMPP?


not sure the version I just downloaded it this week. I think it is 1.7.2
hobbyist
 
Posts: 5
Joined: 30. October 2009 14:17

Re: run from command line

Postby Izzy » 02. November 2009 04:06

hobbyist wrote:I'm typing the commands on the XAMPP for windows screen that shows up when I hit "shell" command from the XAMPP control panel
Type or copy and paste here the exact command(s) you are typing that gives the error message.

You can copy and paste by clicking on the little icon top left of the Shell console window and selecting Edit, then use the appropriate menu items.

You are logged into your XP PC with Administrator privileges?

Here is a copy and paste of what I see on my XP with 1.7.2 and the Shell button when I type at the prompt the first command php -h in my previous post
Code: Select all
Setting environment for using XAMPP for Windows.

Izzy@IZZYS C:\xampp
# php -h
Usage: php [options] [-f] <file> [--] [args...]
       php [options] -r <code> [--] [args...]
       php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
       php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
       php [options] -- [args...]
       php [options] -a

  -a               Run interactively
  -c <path>|<file> Look for php.ini file in this directory
  -n               No php.ini file will be used
  -d foo[=bar]     Define INI entry foo with value 'bar'
  -e               Generate extended information for debugger/profiler
  -f <file>        Parse and execute <file>.
  -h               This help
  -i               PHP information
  -l               Syntax check only (lint)
  -m               Show compiled in modules
  -r <code>        Run PHP <code> without using script tags <?..?>
  -B <begin_code>  Run PHP <begin_code> before processing input lines
  -R <code>        Run PHP <code> for every input line
  -F <file>        Parse and execute <file> for every input line
  -E <end_code>    Run PHP <end_code> after processing all input lines
  -H               Hide any passed arguments from external tools.
  -s               Output HTML syntax highlighted source.
  -v               Version number
  -w               Output source with stripped comments and whitespace.
  -z <file>        Load Zend extension <file>.

  args...          Arguments passed to script. Use -- args when first argument
                   starts with - or script is read from stdin

  --ini            Show configuration file names

  --rf <name>      Show information about function <name>.
  --rc <name>      Show information about class <name>.
  --re <name>      Show information about extension <name>.
  --ri <name>      Show configuration for extension <name>.


Izzy@IZZYS C:\xampp
#
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: run from command line

Postby hobbyist » 03. November 2009 03:31

I am logged in as administrator. Following is what I get when I type php -h

"

Setting environment for using XAMPP for Windows.

Jeff@jeffC:\xampp
# php -h
Access is denied.

Jeff@jeffC:\xampp
#


"
hobbyist
 
Posts: 5
Joined: 30. October 2009 14:17

Re: run from command line

Postby Izzy » 03. November 2009 06:35

Jeff, I can't seem to be able to replicate this issue on any of my 5 XAMPP installed versions, either from the command line (DOS console) or the Windows Shell - I am always allowed access no matter how hard I try.

I have tried various strange setting for file access permissions etc. without success.

The only thing I can think of that may have an effect on this is possibly an Anti-Virus and or a Firewall setting or even such a program as ZoneAlarm and the like which is preventing access to executing the php.exe file - perhaps temporarily disable any and all of the above if you have them installed then try again. If php.exe is allowed then you may have to configure the offending software to allow php.exe to be executed.

You can also look for clues in the Windows Event Viewer by clicking on start in the TaskBar and then selecting Administrative Tools>Event Viewer then double click on Application item and look for php in the source column then double click on the event line for more detail of each event displayed.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: run from command line

Postby hobbyist » 03. November 2009 15:07

Thanks for all your help Izzy. I'll try what you mentioned. I'll let you know what if anything worked for your future info. If all else fails I'll just load Xampp on another computer.
hobbyist
 
Posts: 5
Joined: 30. October 2009 14:17


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 61 guests