Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows/php pclose和popen问题_Php_Windows_Iis_Popen_Pclose - Fatal编程技术网

Windows/php pclose和popen问题

Windows/php pclose和popen问题,php,windows,iis,popen,pclose,Php,Windows,Iis,Popen,Pclose,这是我的密码: <?php require_once 'dbconnect.php'; function execInBackground($cmd) { if (substr(php_uname(), 0, 7) == "Windows"){ pclose(popen("start /B ". $cmd, "r")); } else { exec($cmd . "

这是我的密码:

<?php
    require_once 'dbconnect.php';
    function execInBackground($cmd) { 
        if (substr(php_uname(), 0, 7) == "Windows"){ 
            pclose(popen("start /B ". $cmd, "r"));  
        } 
        else { 
            exec($cmd . " > /dev/null &");   
        } 
    } 

    if(isset($_GET['date'])){
        //CHECK LOCK
        $checkLock = "Select IS_FREE_LOCK('overnight') as `lock`;";
        $result = mysql_query($checkLock) or die(mysql_error());
        while($information = mysql_fetch_array($result)){
            if($information['lock'] == 0){
                die('Overnight is already running, please try again later.');
            }
        }
        execInBackground("php overnightQueries.php {$_GET['date']}");
        //echo "<pre>".print_r($output2, true)."</pre>";
        header('Refresh: 3; url=index.php');
        die('running queries...');
    }
    else {

        die('PLEASE SET DATE');

    }
?>
我使用的是一台windows机器

我收到以下警告:

警告:popenstart/B php overnightquerys.php 2011_08_12,r:第5行的C:\inetpub\GTSA\runOvernight.php中没有错误

以及:

警告:pclose希望参数1是资源,布尔值在第5行的C:\inetpub\GTSA\runOvernight.php中给出

如果存在问题,popen将返回false,您将盲目地将问题传递给pclose,因此出现第二个错误


对于第一个错误,请检查PHP是否在您环境的路径中-您可能需要指定PHP.exe的绝对路径。

hmmm PHP在路径中。我将尝试你的答案,一分钟。现在我得到:无法执行php overnightQueries.php 2011_08_12可能是什么问题?尝试添加一个php的绝对路径,例如c:\bin\php.exe。请注意,如果路径中有空格,则需要引用命令,start有一些奇怪的地方:现在我无法执行c:\php\php.exe overnightQueries.php 2011_08_12基本上是一样的东西还有忘了提到同样的脚本在不同的windows vmI上工作得很好真的不记得@Muhwu:-那是>4年前的事了。哦,哇,没有注意到那一年。不能说我怪你。但这是一个遗憾。我认为这与它如何处理输出有关,因为执行popenstart/B$cmd.>C:\\file.txt,r;可以工作,但是去掉了>C:\。。。分开了,就没有了。
$handle = popen("start /B ". $cmd, "r");  
if ($handle === FALSE) {
   die("Unable to execute $cmd");
}
pclose($handle);