Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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:
    151
    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:
    8
    Trophy Points:
    193
    Hint: Apache server variables are only passed to the script when run from the web
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice