控制台应用的问题

framework\console\CConsoleApplication.php

CConsoleApplication::init();

if(!isset($_SERVER[‘argv’])) // || strncasecmp(php_sapi_name(),‘cli’,3))

die('This script must be run from the command line.');

这两行判断好像有问题。在linux下,用cron运行,输出This script must be run from the command line。

windows下,用浏览器也可以打开,不输出This script must be run from the command line。

请问qiang哥,这怎么解决?

我在cron里运行yiic没问题啊,再详细说一下你的环境吧,具体的cron配置

在godaddy的linux空间上面测试,具体cron配置不清楚。到上面打印$_SERVER,是没有$_SERVER[‘argv’]这个变量的。php_sapi_name()出来是cgi-fcgi。在windows系统运行,用浏览器打印出来,有这个变量。这里根据是否有这个变量来判断是不是在控制台运行,是不准确的。