I am using Php in Linux Cent OS. I wanted to convert PDF to SWF, So I use SWFTools. SWFTools consists of pdf2swf command, which is executing fine when I use it in command line. But the command is not working when I execute it through php.
Error: command not found
I have found the extensions are up to date.
Anything else is missing in between?
Use the full path.
The path environmental variable will be different when running under PHP, since that will run as another user.
Related
I have a very strange problem.
I'm trying to make a program that executes shell_exec() in PHP with NMAP.
The problem comes when I put shell_exec("nmap --version"), because it returns me version 4.11, but when I put it directly on shell, it returns me version 7.01.
When using shell_exec you should always use the full path to the executable.
I'm trying to run a ROS shell program on the server through php on Ubuntu 14.04. I have tried using system, exec, shell_exec but nothing happens and I don't get any output. The system call is the following:
echo shell_exec("/opt/ros/indigo/bin/rosrun gazebo_ros spawn_model -database Part_A -gazebo -model Part_A");
What are the limitations of using system or exec to run any shell command through php on a server?
I don't care as much about the output of the command as for its execution. I think the problem has to do with the fact that PHP doesn't have any PATH like shell does so it can't find any applications without specifying the exact location. How can I make PHP se the same PATH shell does?
The problem was that the apache user and the environment in which the bash commands are running are not set up correctly. I followed the instructions from this answer but instead of using "source" I used "." and instead of using the source.bash file I used the source.sh file. I also set all the environment variables that had to do with ros or gazebo using the putenv() function.
I've followed tutorials and answer here on Stackoverflow, but I still can't access php.exe from command line.
All I get is:
php is not recognized as an internal or external command...
How can I make php.exe accessible from anywhere in the command line?
What else can I try to execute PHP from command line?
Path should be
C:\wamp\bin\php\php5.4.12
without php at end
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
When I try to execute php file from browser which have a command to start AWS ec2 instance I am getting error as ec2start command not found, but when I execute this file from command prompt in Ubuntu it works fine as I am executing this as a root but when I execute this file from browser it get execute with the apache user,
anybody knows the solution for this,
Thanks,
It is quite probable that your command line environment is different from PHP's.
In order to do what you asked for, you need to specify ec2start with an absolute filename.
First run the following from your command prompt to find the path:
whereis ec2start
It should return a list of paths, just find the one containing ec2start.
Next, simply use that path you found inside your PHP script, like so:
shell_exec('/path/to/ec2start');