I am using php version 5.2.17. I have a site build in php and testing it under IIS 5.1 on localhost (windows).
I want to run a lengthy PHP script in background, thereby allowing the user to continue using the site (navigation).
I am trying using popen like this:
$cmd='c:\\php\\php.exe c:\\inetpub\\wwwroot\\download.php';
pclose(popen('start /B '.$cmd, 'r'));
This gives error:
PHP Warning: popen(c:\php\php.exe C:\inetpub\wwwroot\download.php,r) [function.popen]: No such file or directory.
Any clues are highly appreciated.
Try to first execute cmd and then call php over cmd like explained here: http://bytes.com/topic/php/answers/751763-popen-windows
SOLVED: i changed the file security of Download.php in IIS and set the user to IWAM(launch IIS Process account).
Thanks for ull experts who showed concern.
Related
I have the following Problem: If i execute a Shell-Paramter via Shell (cmd.exe) on my Windows Server 2012 it execute perfectly. But if i do the same via PHP (shell_exec) it execute , but with no access to a Template-file.
aerender ERROR: No render settings template was found with the given name.
here is the code
PHP:
<?php
chdir('C:\\Program Files\\Adobe\\Adobe After Effects CC 2015\\Support Files\\');
shell_exec('aerender -project C:\server\htdocs\ae\final3\final.aep
-comp "clouds- rotation-low" -RStemplate "E2Z640blur"
-OMtemplate "E2Z640" -output C:\server\htdocs\cache\clouds-rotation-low.avi')
?>
Yeah, this happens because when PHP opens up the cmd it doesn't load the PATH variables by standard, I think there is a way around that or you can just use an absolute path for aerender
ie. C:\aerender\aerender
Ok, now it works! I just changed the apache2 service in Windows to run as Administrator
When I am using wkhtmltopdf in the terminal it works fine and pdf is generating correctly.
But when I am trying to use this in the php using 'system' command, it fails and gives apache error that 'cannot connect to X-server'.
In php, I used like this.
system("wkhtmltopdf $url output.pdf");
I tried 'exec' instead of system but giving the same problem.
Please help me out.
It might be a permission error if it works via command line but not PHP. Are you working locally or on a remote server? If you're on shared hosting, try contacting support to see if you have permission to call system, exec, or shell_exec.
Alternatively, try redirecting your standard error to a text file, maybe that will steer you a bit in the right direction:
system("wkhtmltopdf $url output.pdf 2> /tmp/error.txt");
In my php code:
exec(test.sh);
and test.sh has code:
echo "Hi this is test?" | espeak --stdout > demo.wav
But nothing happen. No error, No output.
If i try to execute test.sh from terminal that it will work perfectly. So why it not run on my php.
Can someone help me?
How do you run your PHP script? With php-cli (in shell mode)? HTTP (Apache, ...)?
It could be a path problem. Could you give us the path of your test.sh, the path of your php script or the URI which is called to run the PHP if you use apache or other HTTP server?
the apache user will need write access to the current working directory (presumably the same directory that contains your php script and test.sh).
I'm having a look at some PayPal scripts/code examples and a lot of them need a php script running via the command line.
I've never had to run anything from a command line in PHP before so don't know where to start at all. I don't know if I'm using the correct search terms as Google hasn't helped me answer.
Do I need to use a different application or is there something in cPanel I can use?
I get this error:
INSTALLATION ERROR: Please cd to the /home/site_name/public_html/site and run install.php
Use SSH to access the server via the terminal:
http://docs.cpanel.net/twiki/bin/view/11_30/CpanelDocs/ShellAccess
There's instructions on how to connect via PuTTY, then you can go to the directory where the PHP script is run it like:
php myPHPScript.php
If your cPanel has the option to turn on SSH, do it. Then SSH into the server and run the commands -
cd /home/site_name/public_html/site
php install.php
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