I have a web-based script than I can manually update.
For the web interface you must login.
But I want the same script run as a scheduled cli script.
To defeat the login procedure it must reliable detect that the script is executed from the cli.
Is there a reliable way to detect if the script is executed from the cli?
Detect php cli execution
Moderator: General Moderators
- WaldoMonster
- Forum Contributor
- Posts: 225
- Joined: Mon Apr 19, 2004 6:19 pm
- Contact:
- WaldoMonster
- Forum Contributor
- Posts: 225
- Joined: Mon Apr 19, 2004 6:19 pm
- Contact:
Didn't you mean php_sapi_name() instead?
But this returned "cgi-fcgi" from the cli.
It could also be from a web server.
Detecting if one of the following values are set:
Or is this not reliable?
But this returned "cgi-fcgi" from the cli.
It could also be from a web server.
Detecting if one of the following values are set:
Code: Select all
$_SERVER['REQUEST_METHOD'];
$_SERVER['SERVER_PROTOCOL'];
$_SERVER['SERVER_PORT'];
Last edited by WaldoMonster on Thu Mar 22, 2007 7:42 pm, edited 1 time in total.
- WaldoMonster
- Forum Contributor
- Posts: 225
- Joined: Mon Apr 19, 2004 6:19 pm
- Contact: