when I run exec('C:\execute\batfile.bat'); it works when my xampp is installed in
C:
but when I move my codes in another server the xampp there is installed in
D:
so my code exec('D:\execute\batfile.bat'); fails and doesn't show any errors when I test in browser.
Please help on how to run a bat file not saved in C:
Thank you so much
thanks for your suggestion and solutions :)
I follow the suggestion of #preet sangha and find "ERROR: The parameter is incorrect".
Then I researched more on what is the cause of incorrect parameter. Then I stumble upon the answer of juan at laluca and ernestokarim in http://php.net/manual/en/function.exec.php. And I follow the answer of ernestokarim
Start > Run > "services.msc"
Search the Apache Service, right click and select Properties.
You will see two radio buttons, check the first if it isn't, and then
check too the check box below.
Now restart Apache
I realize that for some reason when xampp is installed in C, function exec works fine but when you installed it in other drive it doesn't because of some permission issues.
The above steps solve my dilemma :-)
Try echoing the output, maybe you're just missed something inside the bat file and it's not a php problem
echo system("D:\execute\batfile.bat");
Related
Here is what the control panel looks like
But the output over here seems like it's working??
So far I've tried a whole bunch of terminal commands to force it to start and none of them have worked so far. Then I tried reinstalling but the same problem. I tried changing the port but that didn't work either.
When I run php files in the htdocs folder it works fine though, but phpMyAdmin doesn't connect.
This is error I get when trying to connect to phpMyAdmin
Having just spent hours on this problem, the following answer helped me:
"If the problem is not a busy port you can also try the following: select "show debug information" in the XAMPP config panel. you will find this option in config panel enable this option and click save it will display the files that are being executed, like when starting Apache you'll be shown something like "Executing "c:\xampp\apache\bin\httpd.exe". If you run the same command in cmd prompt it will clearly display the error with file name and line number.
All you need to do is to find the respective file dig in the code and resolve it.Your problem will be [may be] solved."
I installed xammp (php7) on my ubuntu machine. I want to access cli op PHP and MYSQL. Is there any workaround to do this?
OK Finally I found the answer . its by going to opt/lampp/bin/php
OK Finally I found the answer . its by going to opt/lampp/bin/php
This appears as the first StackOveflow link in google search results so I'm leaving this here for future viewers.
Add opt/lampp/bin to PATH by adding the below line to .bashrc
export PATH="/opt/lampp/bin:$PATH"
hey I've got a strange problem, I've read plenty of articles about it on the net and still have no clue what am I doing wrong. Here it goes: I want to build php projects on ubuntu so I got netbeans and wanted to install xampp. I downloaded xamp installer (extension .run) and it doesn't work at all, I mean I tried via terminal and also graphical mode- still nothing. I just run it as it's supposed 2 b run and nothing happens. So I typed in the terminal the following:
strace ./<xampp_installer_name>.run
and I got something like lot of lines but only this one seems 2 contain some error:
open("/lib/ld-linux.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
_exit(127)
Does anyone have any idea what I missed or I am doing wrong with this...? It took a day of my life and I'm out so I'd appreciate any ideas.
peace
You might need the 64 bit version of the xampp installer.
For anyone else who has this problem, rconxs's solution worked for me. If you're new to Ubuntu, you can check if you'll need the 64 bit version by going to System Settings > Details. On the overview page, check to see if the "OS type" is 64 bit. If so, be sure to download the 64 bit installer (should have a file name similar to: xampp-linux-x64-1.8.3-2-installer.run). Then, just follow the rest of the instructions on the apache friends site.
I am trying to execute a php file from sos-berlin jobscheduler. My OS is windows 7. I am following the documentation
http://www.sos-berlin.com/mediawiki/index.php/How_to_execute_a_PHP_script_with_JS
#!/usr/bin/php
<?php
echo "hello";
?>
But when I executed the script I am getting the error that
'#!' is not recognized as an internal or external command, operable program or batch file.
I came to understand that #!/usr/bin/php is a linux command. I should give here equivalent batch command. I googled, but didn't find any useful result. Please any one help me...
Thanks in advance.
Suppose you have installed php.exe in C:\Program files\MyPhpProgram\php.exe
Then run below 2 lines on terminal (cmd.exe):
assoc .php=phpfile
ftype phpfile="C:\Program files\MyPhpProgram\php.exe" "%1"
Go to your desktop.
Right click My Computer shortcut in the desktop.
Click Properties.
You should see a section of control Panel - Control Panel\System and Security\System.
Click Advanced System Settings on the Left menu.
Click Enviornment Variables towards the bottom of the window.
Select PATH in the user variables list.
Append your PHP Path (C:\myfolder\php) to your PATH variable, separated from the already existing string by a semi colon.
Click OK
Open your "cmd"
Type PATH, press enter
Make sure that you see your PHP folder among the list.
That should work.
install a php engine on windows
in a cmd windows for example, run php <path/to/your/script>
open cmd, go to where you installed php. and run c:\program files\php\php.exe <path/to/your/scirpt>.php
link to setting up the path to include php so you can run it easily from cmd:
http://willj.co/2012/10/run-wamp-php-windows-7-command-line/(dead link)
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.