Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. php and batch files

php and batch files

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phptoolscareer
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    simpocoder
    wrote on last edited by
    #1

    Hi, I want a PHP script to run multiple batch files. The batch files are doing the same job but for different files. I don't want to create several scripts to do the same job. Any idea is welcome.

    L 1 Reply Last reply
    0
    • S simpocoder

      Hi, I want a PHP script to run multiple batch files. The batch files are doing the same job but for different files. I don't want to create several scripts to do the same job. Any idea is welcome.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Not knowing exactly what task or tasks you wish to batch perform, and not being a mind reader, may I suggest you visit web sites such as http://www.hotscripts.com/category/php/[^] and look to see if anything there (or elsewhere for that matters) jumps up and says "try me"!

      S 1 Reply Last reply
      0
      • L Lost User

        Not knowing exactly what task or tasks you wish to batch perform, and not being a mind reader, may I suggest you visit web sites such as http://www.hotscripts.com/category/php/[^] and look to see if anything there (or elsewhere for that matters) jumps up and says "try me"!

        S Offline
        S Offline
        simpocoder
        wrote on last edited by
        #3

        The script is as shown below

        <?php
        session_start();
        $userid=$_SESSION['userid'];
        $res=exec('bat\diff_coursework.bat',$shell);
        echo '<a href="content/differentiation_coursework/main.pdf"><input name="Download" type="button" value="Download" />';
        include ("config.php");
        $query="insert into access values('$userid','differentiation','coursework',NOW())";
        mysql_query($query);
        ?>

        It calls the batch file diff_coursework.bat and then display a download button for the main.pdf file. I have several files to be run the same way therefore I need a general script for that instead of creating a new script for every file.

        C 1 Reply Last reply
        0
        • S simpocoder

          The script is as shown below

          <?php
          session_start();
          $userid=$_SESSION['userid'];
          $res=exec('bat\diff_coursework.bat',$shell);
          echo '<a href="content/differentiation_coursework/main.pdf"><input name="Download" type="button" value="Download" />';
          include ("config.php");
          $query="insert into access values('$userid','differentiation','coursework',NOW())";
          mysql_query($query);
          ?>

          It calls the batch file diff_coursework.bat and then display a download button for the main.pdf file. I have several files to be run the same way therefore I need a general script for that instead of creating a new script for every file.

          C Offline
          C Offline
          cjoki
          wrote on last edited by
          #4

          since this part is just a string being passed 'bat\diff_coursework.bat' maybe an array might help $bats_arr = array('diff_coursework.bat','diff_coursework2.bat','diff_coursework3.bat', etc....); foreach($bats_arr as $bat_file) { $res=exec('bat\'.$bat_file,$shell); }

          S 1 Reply Last reply
          0
          • C cjoki

            since this part is just a string being passed 'bat\diff_coursework.bat' maybe an array might help $bats_arr = array('diff_coursework.bat','diff_coursework2.bat','diff_coursework3.bat', etc....); foreach($bats_arr as $bat_file) { $res=exec('bat\'.$bat_file,$shell); }

            S Offline
            S Offline
            simpocoder
            wrote on last edited by
            #5

            Have you tried to implement this? This will run all the bat files every time it is called. I want it to be able select the bat files to run. Thanks for the idea

            C 1 Reply Last reply
            0
            • S simpocoder

              Have you tried to implement this? This will run all the bat files every time it is called. I want it to be able select the bat files to run. Thanks for the idea

              C Offline
              C Offline
              cjoki
              wrote on last edited by
              #6

              Then in your code reference the array by the index via a link. That will give you the selection you want and a single file to manage them all.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups