Run a script from within a script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #1

    Run a script from within a script

    I am writing a script 'stockAvailibil ty.php' that creates a spreadsheet of stock availability from a MySql database.
    But the MySql database needs updating from a MsSql database first, and
    I have a script that succesfully does this 'updateStockLev el.php'..
    So what is the best way to run 'updateStockLev el.php' from 'stockAvailibil ty.php'
    prior to the rest of the script executing.
    I prefer not to use 'include' because they both share similar classes and functions that will cause a redeclaration headache.
    Also it needs to allow time for the MySql database to finish its UPDATE
  • pimmy
    New Member
    • Nov 2007
    • 9

    #2
    Have you thought of calling a procedure from your PHP script which will first update the database and then get you the data?

    Cheers,
    Pimmy

    Comment

    • code green
      Recognized Expert Top Contributor
      • Mar 2007
      • 1726

      #3
      Updating the MySql DB from the MsSQl is quite complex, involving calculations and multiple SELECTs.
      updateStockLeve l.php achieves this but needs to remain as a standalone because this is a seperate script running on a scheduled task.
      I don't want to copy all this code (200 lines + mutiple class and function includes) in to stockAvailibili ty.php because it would need some re-writing.
      I just want to run updateStockLeve l.php from stockAvailibili ty.php.

      Comment

      • pimmy
        New Member
        • Nov 2007
        • 9

        #4
        Then would this work for you:

        shell_exec('php updateStockLeve l.php');

        Cheers,

        Pimmy

        Comment

        • code green
          Recognized Expert Top Contributor
          • Mar 2007
          • 1726

          #5
          Thanks pimmy I will give it a try.
          After some Googling I had a look at exec() and system() but didn't seem to be suitable.
          There is also a bit of HTML using the src tag <src="updateSto ckLevel.php">
          which I thought was interesting.
          Only ever used exec() to run a mysqldump command so I wasn'.t sure how to achieve this.

          Comment

          Working...