1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to Run PHP SCRIPT from another PHP script on the same server ?

Discussion in 'PHP' started by deriklogov, Jun 25, 2009.

  1. #1
    How to Run PHP SCRIPT from another PHP script on the same server ?
    SEMrush
     
    deriklogov, Jun 25, 2009 IP
    SEMrush
  2. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What do you mean 'run'? You can use CURL I do believe to do it! :)
     
    Wrighty, Jun 25, 2009 IP
  3. Romocop

    Romocop Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    include("scriptnamehere.php");

    Is that what you are talking about?
     
    Romocop, Jun 25, 2009 IP
  4. deriklogov

    deriklogov Well-Known Member

    Messages:
    1,069
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    130
    #4
    Thanks for reply,
    but include doesnt help, and I dont want to use curl,
    any other way ?
     
    deriklogov, Jun 25, 2009 IP
  5. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Why don't you want to use curl?
    Final thing is to use some AJAX ... that's all that I can think of! :-/
     
    Wrighty, Jun 25, 2009 IP
  6. Vooler

    Vooler Well-Known Member

    Messages:
    1,138
    Likes Received:
    63
    Best Answers:
    4
    Trophy Points:
    100
    #6
    Using CGI version:
    exec("php -q SCRIPT_PATH_AND_FILENAME",$o,$r);


    Using the CLI SAPI yields:
    exec("php -f SCRIPT_PATH_AND_FILENAME",$o,$r);


    I hope it helps you find out what you need, or probably it is what you need.

    regards
     
    Vooler, Jun 25, 2009 IP
  7. Vooler

    Vooler Well-Known Member

    Messages:
    1,138
    Likes Received:
    63
    Best Answers:
    4
    Trophy Points:
    100
    #7
    Adding few more cents.

    If you need to execute a php script at a schedule then use CRON JOB at unix/linux and Task Schedular at Windwos, rather than using exec, because this function might have been disabled at certain servers.

    regards
     
    Vooler, Jun 25, 2009 IP
  8. Bohra

    Bohra Prominent Member

    Messages:
    12,579
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #8
    Why doeesnt include help ?? include works always ? unless these files are on diffrent accounts
     
    Bohra, Jun 25, 2009 IP
  9. susan8051

    susan8051 Peon

    Messages:
    1,358
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #9
    when including use the absolute paths like

    include("/home/username/public_html/script1/script.php");
     
    susan8051, Jun 26, 2009 IP
  10. thuankkk

    thuankkk Active Member

    Messages:
    503
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    95
    #10
    you can try this, if allow_url_fopen is enable:
    file_get_contents("http://yoursite.com/yourscript.php");
    PHP:
    Or, if you need to call a .php file periodically, try this free cron service.
     
    thuankkk, Jul 6, 2009 IP
  11. xrvel

    xrvel Well-Known Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    175
    #11
    You can use include (or such) , curl, or exec(), depend on your situation & need.
    What is the problem in your script?
     
    xrvel, Jul 7, 2009 IP
  12. TecBrat

    TecBrat Member

    Messages:
    31
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #12
    Derik,

    Please give more detail about what you are trying to do. Otherwise we are guessing when we try to help.
     
    TecBrat, Jul 7, 2009 IP