I'm trying to get started with using Google app engine with PHP (on Windows 7) and have been trying to follow the helloworld example here.
Problem I am having is in starting the webserver. Whenever I try to run it I get the error
dev_appserver.py: error: too few arguments
I'm typing the following at the command line:
google_appengine\dev_appserver.py --php_executable_path=c:\php\php-cgi c:\appengine\helloworld\
Any suggestions as to what I am doing wrong?
Cheers
Use quotes for arguments.
google_appengine\dev_appserver.py --php_executable_path="c:\php\php-cgi" "c:\appengine\helloworld"
Or use slashes instead of backslashes as directory separator:
google_appengine\dev_appserver.py --php_executable_path=c:/php/php-cgi c:/appengine/helloworld
For best results combine both methods ;)
So I was running into this issue, and tried every permutation of paths using quotes, and switching to the directory where appengine SDK was installed etc. Finally I realized that Python was running the script but it wasn't including the command line arguments being passed in. So I had to manually call python like this:
c:\<python_path>\python <sdk_path>/dev_appserver.py --php_executable_path=c:/php/php-cgi.exe helloworld/
I'm not a python guy so I don't know why the command line arguments got stripped, but I've had this issue with other applications in Windows 7
This answer solved the issue for me.
Just to clarify it a bit, here is how the value under
HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command
should look in Windows regedit tool.
And it should be the same as the value under this path:
HKEY_CLASSES_ROOT\Python.File\shell\open\command
Solution tested on environment: Python 2.7.5 on Windows 7 (Home Premium) x64.
In fact I had this problem not with PHP App Engine but with Go App Engine. However, it is apparently not App Engine, but rather a Python+Windows issue.
I'm using Windows 7 too.
Here it's my code tested:
dev_appserver.py --php_executable=c:/php/php-cgi.exe c:/appengine/helloworld
Notice! I'm inside google appengine directory.
For example if you installed the SDK in C:
Write first cd google_appengine hit enter, and then use the upper code.
You have to either: give full path to dev_appserver.py
or
cd into the directory where you instaled it
If You followed example to the letter You would have instaled it in C:/{username}/something directory
and the call would be then something/dev_appserver.py as stated in example in helloworld!
Hovever - the example have one error in it: the directory they are proposing is not the same they are using in example call! Thats why make sure the "sometinhg" directory is the same in call as used to instal app engine
after I moved everything to c:\ to simplify the paths I ended up calling it from the dos command prompt like this
C:>\Python27\python C:/google_appengine/dev_appserver.py --php_executable_path=
C:/php/php-cgi.exe c:/google_appengine/helloworld/
And it works!
is the python command line tool the way we should be running this stuff?
Related
I'm trying to execute a command through shell_exec in php. But I'm getting an error.
My code :
shell_exec('groovy log_analyser1.groovy').
But I'm getting this error :
sh: groovy: command not found
Put groovy installation somewhere sane (/usr/local or /opt or whatever your ops team allows you) and then call groovy with the absolute path.
Since you have currently installed in in your root users ~, other users (like the user your php/httpd runs as) don't have access to it (for good reasons).
Even if you would use the same user as your php/httpd and use GVM there you will have a hard time to make this work properly, since GVM relies on some scripts to run. So just copy from your GVM files (~/.gvm/groovy/<version>) where it's easy for all users to access it.
Finally got the output. I have moved the groovy directory from /root to /usr/share/. Then gave the groovy path in my php file. Now its working fine. To set java environmental variable.
I have set this putenv("JAVA_HOME=/usr/share/java/jdk1.7.0_03/");
$result = shell_exec('/usr/share/groovy/2.4.3/bin/groovy log_analyser1.groovy');
Thanks Cfrick for the help.
echo $result;
I am running a local WAMP on my Windows 7 with a PHP script that executes a windows command as follows:
`exec('"%CD%\files_for_redistribution\ppt2html5.exe" /i:"%CD%\test.ppt" /o:"%CD%\output.html" /title:title /desc:description /author:author /keywords:keywords',$output,$error);`
The command when run from a batch file does the job well but when run from PHP script, gives an error:Presentation opening error: PowerPoint could not open the file.
The intention of the command is to convert PowerPoint to HTML using a third party software called ppt2html5.exe where test.ppt has to be converted to output.html.
I have found lot of blogs discussing about exec function not working properly but nothing really helped me to deal with this error as it runs the command but cannot open the file.
It would be great if somebody could help me with this.
Check if safe mode is on, because that activates escapeshellcmd and some characters are escaped.
Assuming that the string that you are passing to exec(), including percentage signs, routes and parameters are right, your problem may be related to permission of files and user executing apache + php, check that.
Fixed by adding a folder named Desktop inside C:\Windows\System32\config\systemprofile.
Source:http://www.sitepoint.com/forums/showthread.php?956457-Windows-2008-PHP-new-COM%28powerpoint-application%29
I assume I'm making some simple mistake, but I just can't get the Google App Engine PHP SDK (GAE) "helloworld" example to work.
When I attempt to run the example on a Windows XP command line, I get no errors. The dev appserver is ever started on port 8080. I followed the GAE PHP SDK "Getting Started" page to the letter. If I mistype the path name, I get an error on that, but that’s it.
I have installed Python 2.7, PHP 5.4 and the GAE PHP SDK 1.8.3. All seem to work independently without error. Testing such…phpinfo() works, the Python interpreter works as well.
I’ve read all of the other questions/answers on this subject on the Stack(here) but nothing has helped. Here's some details:
My "helloworld" dir (the app.yawl file is there too):
C:\helloworld\helloworld.php
My Google GAE dir:
C:\google_appengine
My PHP dir:
C:\PHP
My Python dir:
C:\Python27
Here's the dev appserver startup command line I'm using in a Windows XP CMD window:
python C:\google_appengine\dev_appserver.py --php_executable_path=C:\PHP\php-cgi.exe C:\helloworld\helloworld
The dev web server does not start, can't see the listener on default port 8080 in netstat.
You said that the app.yawl file is present in the helloworld directory.
Its actually app.yaml . You may have saved that with incorrect extension. Check it.
The other thing I noticed is in the last command you are pointing to the .php file as C:\helloworld\helloworld.
You should actually point to the APPLICATION_DIRECTORY, which in your case is just C:/helloworld/
I'm attempting to run an application on the server, invoking it from PHP using the following code.
$application = "D:\\Program Files (x86)\\ScanBoy\\DM ScanBoy.exe";
exec($application);
Right now the application is 'run' however it crashes instantly. If I just run the application (by double clicking the exe) it runs and everything is fine.
When the application crashes the only error I get is
"{application name} has stopped working. Windows is checking for a
solution to the problem"
I have had this problem with running application via c# backend to a ASP.NET page. The solution there was to set the Working Directory. However in php / exec I am unaware of how to set this option.
Any help please?
You can either:
Use exec("cd myworkdir/ && D:\\Program Files (x86)\\ScanBoy\\DM ScanBoy.exe"); to change the working directory for that exec command (only)
Use the php chdir() function to change the working directory of the php process.
You can find chdir documentation here:
http://php.net/manual/en/function.chdir.php
You can chdir() to change current working directory
I am using this php code:
exec("unrar e file.rar",$ret,$code);
and getting an error code of illegal command ie 127 ... but when I am using this command through ssh its working ... because unrar is installed on the server ... so can anyone guess why exec is not doing the right stuff?
Try using the direct path of the application (/usr/bin/unrar of whatever), it sounds like php can't find the application.
If you have chrooted apache and php, you will also want to put /bin/sh into the chrooted environment. Otherwise, the exec() or passthru() will not function properly, and will produce error code 127, file not found.
Since this comes up as a top answer in google, I wanted to share my fix:
The simple fix I had was to disable safe_mode in the php.ini file
; Safe Mode
; http://www.php.net/manual/en/ini.sect.safe-mode.php#ini.safe-mode
safe_mode = Off
thanx all for your response!!
I tried this
//somedir is inside the directory where php file is
chdir("somedir");
exec("/home/username/bin/unrar e /home/path/to/dir/file.rar");
and now it returned no exit code ... oher commands are doing file .. i tried mkdir etc .. :s
Just in case somebody else still gets this problem, take a look at the post here:
http://gallery.menalto.com/node/2639#comment-8638
Quote:
I found the problem. The problem was my security-paranoid OpenBSD. When upgrading from 3.1 to 3.2 they added:
Apache runs chroot'd by default. To disable this, see the new -u option.
The chroot prevented Apache from accessing anything outside of a directory, so I moved everything into the apache directory including netpbm. Everything was accessible and executable, but I guess it was still in some sort of "safe mode" because the exec() always returned 127.
Anyway, running httpd with the -u option went back to the less secure non chroot'd apache startup, which allowed the exec() to work again.
ohkiee guyz thanx ... and yes there might be some errors with $PATH ... but with given full path its working :)
exec("/home/user/bin/unrar e /home/user/xxx/yyy/file.rar");
I did not find the solution for my problem of the same type so sharing what was the cause of it in my Linux setup.
For whatever reason I needed an apache module loaded before other modules and so apache was started with LD_PRELOAD. As exec inherits the environment of the parent process LD_PRELOAD was used for starting the exec-ed program (through sh). Now the preloaded module uses some bindings to apache functions and of course they are not to be present in sh. The result of the php exec was an exit status of 127. The solution was to have in my php file a putenv("LD_PRELOAD") that gets executed before any exec calls.