Re: Need best way to determine if cronjob or external browser called my script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2005-01-19 at 07:47, Al wrote:
> I'm working on a script that can be initiated by a cronjob or from a browser.
> 
> I want the script to act differently depending on which one called it.
> 
> -- 

I do not know what the definitive answer is but there are a bunch of
environment differences.  Here is one taken from 

http://us2.php.net/features.commandline

[bhughes@sonecdm elevatetest]$ cat testbrowser.php
<?php
if ($_SERVER['SERVER_PORT']) { echo "SERVER MODE\n"; } 
else { echo "CLI MODE\n"; } 
?>


results from wget:

[bhughes@sonecdm elevatetest]$ wget -q --output-document=-
https://localhost/elevatetest/testbrowser.php 
SERVER MODE
[bhughes@sonecdm elevatetest]$ 

results from cli 

[bhughes@sonecdm elevatetest]$ php testbrowser.php 
Content-type: text/html
X-Powered-By: PHP/4.3.6

CLI MODE
[bhughes@sonecdm elevatetest]$ 

mozilla returns 

SERVER MODE

HTH

Bret

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux