Cron tabs using a file in a password protected directory

Discussion in 'Site & Server Administration' started by Weirfire, Mar 24, 2006.

  1. #1
    I want to use a cron job to load a file which is in the admin area of one of my sites. How do I get round the password protection using the cron?

    Cheers
     
    Weirfire, Mar 24, 2006 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    How are you trying to access it? Directly in the file system or via an HTTP request to the web server?
     
    digitalpoint, Mar 24, 2006 IP
  3. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #3
    http://login:password@www.thesite.com/adminarea/tool.php
     
    exam, Mar 24, 2006 IP
  4. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #4
    Wow you're up to 15K posts now.

    I'm doing it through cpanel and I'm accessing it with /home/<user>/public_html/admin/file.php
     
    Weirfire, Mar 24, 2006 IP
  5. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You should be able to access it via the file system. The webserver doesn't have any control over that.
     
    exam, Mar 24, 2006 IP
  6. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #6
    Just giving what you said a go now exam.

    -> No such file or directory

    Do I need to put in the HTTP:// before the www?
     
    Weirfire, Mar 24, 2006 IP
  7. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hmmm no. If you have a directory say

    http://www.somesite.com/secret/

    That's protected via HTTP authentication,
    You should be able to log in automatically by browsing to

    http://username:password@www.somesite.com/secret/
     
    exam, Mar 24, 2006 IP
  8. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #8
    But is that what you would use in the cron tab? :)

    Man I'm confused! lol
     
    Weirfire, Mar 24, 2006 IP
  9. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #9
    No, that's just the URL to go to in your cron tab.

    A cron job might look like this:
    
    12 20 * * * root curl "http://username:password@www.somesite.com/secret/s.php"
    Code (markup):
    If you have curl installed, this will call the s.php script every day at 8:12 pm
    Teh *** stands for day, month and weekday respectively.
     
    exam, Mar 24, 2006 IP
  10. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #10
    I just put them in the cpanel

    I tried using curl before but gave up lol. If I can't get it to work in cpanel I'll give that a go.

    Thanks again exam.

    The solution is chmoding the file to 700 and putting php in front of the path to the file.

    So it would be;

    php /home/cpanelname/public_html/admin/file.php
     
    Weirfire, Mar 24, 2006 IP