开发者

system() not working in php using windows server 2003

i have to extract the cabfile(.cab) on the server. i am Finding such script which extract cab file but i didn't get it yet. So now i am try to e开发者_JAVA技巧xtract using cabarc.exe. But i face the problem that when i run command throuw commandline its work fine but when i give same command to system() or exec() function in php it is not work. code is as follow:

    $command = "c:\\exe\\cabarc X c:\\cab\\data.cab c:\\data\\";
if(($output = system($command,$return) != false)
{
  echo "$return";
}

it is not working when i use same string in commandline it works fine. please any body help me to why it not working what to do tomake it work is ther any rights issue. I had give the execute permission to the site.

thanks


The 2nd argument to the system function is passed by reference so it needs to be initialized by your code. Also, you should check for false using !== not != because it validates type in addition to value. Additionally, it looks like you've got an unbalanced parenthesis in your if statement. Try this:

$command = "c:\\exe\\cabarc X c:\\cab\\data.cab c:\\data\\";
$return = -1;
$output = system($command, $return);
if($output !== false)
{
    echo "Return value is: " . $return . "\r\n";
    echo "Output is:\r\n" . $output . "\r\n";
}

If that doesn't fix your issue, make sure the PHP user has permissions to access the file.


If you're using NTFS, check your file permissions and make sure the web server can run that executable, open the source file, and write the destination.


Another problem might be that the program is not allowed to run cmd.exe, maybe see if the IUSR account can execute this program as system needs to invoke a shell.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜