The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Should be easy: Determine is script is running as shell or web?

Discussion in 'General Discussion' started by mmatos, Dec 12, 2006.

  1. mmatos

    mmatos Member

    Joined:
    Dec 9, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    I have a script that I wrote that does some maintenance. I called it regularly using a cron job to fetch the url: (fetch http://www.myserver.com/script.php).

    I'm making some changes and am now doing it like this:

    /usr/local/bin/php /path/to/my/script.php

    Now, the script will usually be called this way, BUT on occasion I will need to call it by hand.

    I'd like to change the line feeds from \n to <br> depending on whether it's run locall or through a page request.

    I can't seem to find any documentation on determining what environment PHP is running in. I'm sure it's something easy like "IsShell()" or something...

    Help? Thanks!
     
  2. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    Hint: Apache server variables are only passed to the script when run from the web
     
Loading...

Share This Page