How to detect if application was initialized from yiic shell command?

Is there any way for web application components (like for example 'viewRenderer') to detect if application was initially started as ./protected/yiic shell ?

The problem is, I have a viewrenderer component, which rewrites some urls: http://www.yiiframew…aseurlappender/

This extension needs write support for some folders (assets). In case you are a linux user you can run into a problem that these folders are not write-accessible for you, e.g. they were created by a webserver user (user apache for example), so when yiic shell starts (as user 'you') it tries to run faked webapplication, which in turn generates default site/index view, and my custom viewRenderer will fail to save a file, will throw CHttpException and as result yiic shell will terminate.

Of course it is easy to fix permissions, but I would like to find a way to detect if application (and components) were initialised from yiic shell command.

At present I've implemented getViewFile() method as follows:



    protected function getViewFile($file)


    {


        if(basename($_SERVER['PHP_SELF']) != 'index.php'){


            return $file;


        } else {


            return parent::getViewFile($file);


        }


    }


But I don't like this solution. Is there any better one?

You can use isset($_SERVER['argv']) to check if it is running in command line mode.

Thanks!

Unfortunately $_SERVER['argv'] under Apache +mod_php is also set and contains request params array. So I will stick with my way for now, anyway - thanks for a quick reply!