php help please <-click

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mr Pheer
    So Fucking Banned
    • Dec 2002
    • 22083

    #1

    php help please <-click

    how do i run a php file from the command line?

    I'm trying to add it to cron, but just pasting the path to the file is not working

    help please
  • mrthumbs
    salad tossing sig guy
    • Apr 2002
    • 11702

    #2
    do it through wget..

    so

    wget "www.site.com/script.php?var=bla"

    Comment

    • woj
      <&(©¿©)&>
      • Jul 2002
      • 47882

      #3
      /usr/bin/php /path/to/the/phpfile.php
      Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
      Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
      Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

      Comment

      • vending_machine
        Confirmed User
        • Jun 2002
        • 1070

        #4
        If you have the php binary installed on your system (try 'which php' ) to see if you have it installed, you can do:

        Code:
        /path/to/your/php /your/file.php

        Comment

        • Mr Pheer
          So Fucking Banned
          • Dec 2002
          • 22083

          #5
          thanks guys

          Comment

          • polle54
            Confirmed User
            • Jul 2004
            • 4626

            #6
            my cronjobs are setup like this, have no idea if you can use this as an example.

            00,15,30,45 * * * * cd /www/virtual/something/www.lalalalala.com/htdocs/jobs; /usr/local/bin/php toplist.php3 >/dev/null
            ICQ# 143561781

            Comment

            • Varius
              Confirmed User
              • Jun 2004
              • 6890

              #7
              Normally in the php script itself, I just set as the first line:

              #!/usr/local/bin/php -q (the -q is for quiet mode, so it doesnt echo the php version and all that)

              Of course that should be set to wherever php binary is on your machine.

              Then you just need to have the path of that script in your crontab, nothing additional.
              Skype variuscr - Email varius AT gmail

              Comment

              • Mr Pheer
                So Fucking Banned
                • Dec 2002
                • 22083

                #8
                ok, dont have wget on the server and cant do it thru cron with php cause it needs to run on the domain itself because of permissions

                any ideas?

                Comment

                • Varius
                  Confirmed User
                  • Jun 2004
                  • 6890

                  #9
                  Originally posted by MrPheer
                  ok, dont have wget on the server and cant do it thru cron with php cause it needs to run on the domain itself because of permissions

                  any ideas?
                  My post above can't work for you ?

                  If you don't have permissions to execute the php binary on the system, then accessing it via web seems to be the only way. Two options there are via curl, if its installed, or lynx (again if its installed).
                  Skype variuscr - Email varius AT gmail

                  Comment

                  • Mr Pheer
                    So Fucking Banned
                    • Dec 2002
                    • 22083

                    #10
                    Originally posted by Varius
                    My post above can't work for you ?

                    If you don't have permissions to execute the php binary on the system, then accessing it via web seems to be the only way. Two options there are via curl, if its installed, or lynx (again if its installed).
                    i guess i'm fucked cause neither is installed. its not a file permission thing, the domain is encoded in the script, and it has to be run on the domain itself, filepath isnt working

                    Comment

                    • ArcherJanvier
                      Confirmed User
                      • Sep 2005
                      • 194

                      #11
                      Sorry, wrong thread
                      Last edited by ArcherJanvier; 10-20-2005, 06:47 PM.

                      Comment

                      • Varius
                        Confirmed User
                        • Jun 2004
                        • 6890

                        #12
                        Originally posted by MrPheer
                        i guess i'm fucked cause neither is installed. its not a file permission thing, the domain is encoded in the script, and it has to be run on the domain itself, filepath isnt working
                        Ok, I understand now, that (I assume) for security, the script was designed to only run on that specific domain....

                        Another option you could do is write a php script that you will call from the cron, looking something like this:

                        PHP Code:
                        #!/usr/local/bin/php -q
                        
                        <?PHP
                        set_time_limit(0);
                        
                        fopen('http://www.domain.com/whatever.php','r');
                        exit;
                        
                        ?>
                        This assumes of course that the servers has allow_url_fopen enabled, which it normally is by default I believe (so if you get a warning and the fopen fails could be because someone has disabled that).
                        Skype variuscr - Email varius AT gmail

                        Comment

                        • Mr Pheer
                          So Fucking Banned
                          • Dec 2002
                          • 22083

                          #13
                          Originally posted by Varius
                          Ok, I understand now, that (I assume) for security, the script was designed to only run on that specific domain....

                          Another option you could do is write a php script that you will call from the cron, looking something like this:

                          PHP Code:
                          #!/usr/local/bin/php -q
                          
                          <?PHP
                          set_time_limit(0);
                          
                          fopen('http://www.domain.com/whatever.php','r');
                          exit;
                          
                          ?>
                          This assumes of course that the servers has allow_url_fopen enabled, which it normally is by default I believe (so if you get a warning and the fopen fails could be because someone has disabled that).

                          That worked!

                          thanks man... you rock!!

                          Comment

                          • OzMan
                            Confirmed User
                            • Sep 2003
                            • 9162

                            #14
                            Is this related to this by chance? One of the options I suggested should work assuming file permissions are set to 777 or whatever they need to be.

                            edit: nm you figured it out

                            Comment

                            Working...