#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    UK
    Posts
    7
    Rep Power
    0
    I am trying to run a script from unix command line and all I get is
    PHP: is a Directory

    I am a Newbie so please forgive my ignorance

    PHP is with APACHE on a cobalt RAQ loaded from RPMs
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    32
    Rep Power
    15
    Although I'm not too knowledgable in this field, I believe you must compile PHP as a binary to get this to work. PHP is not a command line script generally, which is what CRON runs. Search this forum and I'm sure you'll find many posts dedicated to this topic.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    A little advice: if you can, rewrite that script in Perl and run it from cron. It will be much easier.

    If you can't do that, just follow the instructions on installing PHP as a CGI application, and then point to your script from cron.
  6. #4
  7. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    You DO NOT have to compile php as a cgi to run it as a cron job. You can use lynx to call the php script as a web page and dump the results. I often will dump to a log so I can save results with a simple print in the script without having to go thru the gyrations of opening a file, etc. Also, works great when debugging the script as results are just printed to the screen, no need to open the log file to read the output.

    The syntax (off the top of my head):

    lynx -dump /path/to/file.php > /path/to/the/file.log

  8. #5
  9. No Profile Picture
    Viper_SB
    Guest
    Devshed Newbie (0 - 499 posts)
    The syntax (after checking)

    lynx -dump http://192.168.1.1/index.html (change to your address, you have to have the http:// if you want it to run the PHP script)

    ------------------
    Viper_SB
  10. #6
  11. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Yep. Thanks for save, viper.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    London/UK
    Posts
    91
    Rep Power
    14
    BUT if you use lynx you've got the extra overheads of a apache (or whatever) surely?

    This sounds a clever way of cronning PHP if you only have a module version of PHP, but if you have the option of both, I would recommend using the CGI.

    I'll get my coat...

    ------------------
    http://back-end.org
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    1
    Rep Power
    0
    There is another very easy way to do this.

    1. Get the script working when called from a browser.

    2. Try running the script from the command line using "curl". You should get the same results as when you ran the script from the web brouser.

    3. crontab curl {script}

  16. #9
  17. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Bealers,

    If you have apache running with PHP as a DSO, the overhead of having apache serve the script is less than the overhead of launching an independent php interpreter.

    Of course, launching wget, lynx, etc may cost more than launching php, but I bet it's a wash. Close enuf I imagine that it's not worth installing the extra php cgi.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    London/UK
    Posts
    91
    Rep Power
    14
    Ok, I agree that it's a close call, but I'd be interested to see some benchmarks

    regs

    bealers

    ------------------
    http://back-end.org
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    UK
    Posts
    7
    Rep Power
    0
    Guys thanks for all the advice,

    But I dont have lynx and I do not think installing php as a cgi app is an option so I looking at WGET is this an appropriate tool to use

    Once again thanks for all the advice

Similar Threads

  1. php script won't work inside "cgi-local" directory
    By Volitics in forum PHP Development
    Replies: 5
    Last Post: April 26th, 2004, 10:50 PM
  2. How to see the Memory used by a PHP script?
    By Pardall in forum PHP Development
    Replies: 4
    Last Post: February 13th, 2004, 03:54 PM
  3. Getting a script run from apache to not execute as apache
    By freddie_dale in forum Apache Development
    Replies: 2
    Last Post: February 7th, 2004, 06:00 PM
  4. Replies: 1
    Last Post: February 4th, 2004, 01:39 PM
  5. cron doesn't run script
    By vladkornea in forum Linux Help
    Replies: 0
    Last Post: February 2nd, 2004, 02:32 PM

IMN logo majestic logo threadwatch logo seochat tools logo