generatedb.php
<?php
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
echo 'This is a server using Windows!';
$output = shell_exec("C:\\cygwin\\bin\\bash.exe --login -c C:\\cygwin\\bin\\mysql2sqlite.sh -h 127.0.0.1 -u root -pApacheah64 db_shuttlebus tbl_driver tbl_location tbl_rate tbl_route tbl_routeid tbl_vehicle | C:\\cygwin\\sqlite3.exe C:\\Inetpub\\wwwroot\\BusTicket\\exportdatabase\\database.sqlite");
echo "<pre>".$output."</pre>";
} else {
echo 'This is a server not using Windows!';
$output = shell_exec("bash mysql2sqlite.sh -h 127.0.0.1 -u root -pApacheah64 db_shuttlebus tbl_driver tbl_location tbl_rate tbl_route tbl_routeid tbl_vehicle | sqlite3 /var/www/BusTicket/exportdatabase/database.sqlite");
echo "<pre>".$output."</pre>";
}
?>
this is the error out the output
Warning: shell_exec(): Unable to execute 'C:\cygwin\bin\bash.exe --login -c
C:\cygwin\bin\mysql2sqlite.sh -h 127.0.0.1 -u root -pApacheah64 db_shuttlebus tbl_driver
tbl_location tbl_rate tbl_route tbl_routeid tbl_vehicle | C:\cygwin\sqlite3.exe
C:\Inetpub\wwwroot\BusTicket\exportdatabase\database.sqlite' in
C:\Inetpub\wwwroot\BusTicket\exportdatabase\generatedb.php on line 4
if i manually open cmmand promt and run the command are working fine, but when in PHP then it is can't work. why?
i have checked php.ini safe mode are off and disable_functions = are blank.
and this is my phpinfo.php

this is i m using cmd.exe to run the command, it is working

Knowing IIS, there are probably multiple possible explanations. Here's one I found on http://www.php.net/shell_exec
Got the error "Unable to execute..." when trying to run an external program with shell_exec under Windows XP, IIS 5, php 4.3.7 Solved by giving the IIS user (IUSR_...) execution privileges on the system file %systemroot%\system32\cmd.exe This should be used carefully because may represent a server's security hole.
HTH.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With