Hello,
i was wondering if is it possible to make a script that is able to be executed from a webserver and from a CLI aswell.
I'm not shure how to check if variables are passed trough an url or by command line.
I've heard that execution time from CLI to regular php execution, is it true?
Scuar.
Script for a web server and CLI
Moderator: General Moderators
Re: Script for a web server and CLI
Yes, it is possible.
Although, the CLI php.ini settings file may differ from the web server php.ini settings file.
I'm not sure if this is needed, but in your script, you can check if running from the browser or command line by doing this:
Although, the CLI php.ini settings file may differ from the web server php.ini settings file.
I'm not sure if this is needed, but in your script, you can check if running from the browser or command line by doing this:
Code: Select all
$cli = isset($_SERVER['argc']) && ($_SERVER['argc'] >= 1);
if ($cli)
{
//command line
} else
{
//browser
}Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: Script for a web server and CLI
Delete this post please
Last edited by scuar on Fri Nov 05, 2010 9:23 am, edited 1 time in total.
Re: Script for a web server and CLI
Great!, it was so simple.
Thanks a lot.
EDIT:
Oops i didn't realize i misspell this question "I've heard that execution time from CLI to regular php execution, is it true?"
What i need to know it's if a cli script can be executed for hours or days (i'm plaining on using sleep() and each hour do something) and if a web script can do it as well.
Thanks a lot.
EDIT:
Oops i didn't realize i misspell this question "I've heard that execution time from CLI to regular php execution, is it true?"
What i need to know it's if a cli script can be executed for hours or days (i'm plaining on using sleep() and each hour do something) and if a web script can do it as well.