How to execute an external PHP file from a Windows Command Line (bat file) -


i have .bat file on our local network processes file on local shared drive , saves said local drive specific name.

i have .php file on our web server (hosted externally hosting company) takes file- uploaded via form in web browser- , explodes , and enters data mysql database (also on external web server).

i want modify .bat file 'send' file external php script , run external php file without opening browser window. purpose automate entire process our end users can run .bat file , external database updated.

so far, can find how trigger .bat php, opposite of i'm looking for. our network not have web server or php installed , cannot be.

i found executing local php file:

    c:\php5\php.exe -f "c:\php scripts\script.php" -- -arg1 -arg2 -arg3 

i apologize if stupid question- i'm web developer , while knowledge of web languages great, knowledge of languages dos on par 3 year old.

here's php working (this modified bit basic functionality same:

include "dbcommon.php"; //connect database $conn = mysql_connect($dbhost,$username,$password) or die ("could not connect employee database"); @mysql_select_db($dbname,$conn); $uploaded_file = "employees.csv"; if ( move_uploaded_file ($_files['infilename'] ['tmp_name'], $uploaded_file) ) { //open uploaded file $result = file_get_contents($uploaded_file); if ($result === false) {     $error = "could not read $uploaded_file.<br>"; } else {     $error ="";     $query = "delete employees";     $delresult = mysql_query($query,$conn);     if (!$delresult)         $error .= '<br>error deleting existing employee records.';      $lines = explode("\r\n", $result);     foreach ($lines $line)     {         $field = explode(",", $line);         $employee_id = str_replace('"','', $field[0]);         $last_name = addslashes(str_replace('"','', $field[1]));         $first_name = addslashes(str_replace('"','', $field[2]));         $supervisor_id = str_replace('"','', $field[3]);  // if required fields have value, insert row         if ($employee_id != "" && $last_name != "" && $first_name != "")         {             $query="insert employees (employee_id, last_name, first_name, supervisor_id) values ('$employee_id', '$last_name', '$first_name', '$supervisor_id')";             $result = mysql_query($query,$conn);             if (!$result)                 $error .= '<br>error inserting "'.$employee_id.'","'.$last_name.','.$first_name.'","'.$supervisor_id.'"';         } // if required field has value set, report error         elseif ($employee_id != "" || $last_name != "" || $first_name != "")           {             $error .= '<br>error inserting "'.$employee_id.'","'.$last_name.','.$first_name.'","'.$supervisor_id.'"';         }        }     if ($error == "")         $error = "successfully uploaded , inserted employee records.";  }  } else {    $error = "";  switch ($_files['infilename'] ['error'])  {       case 1:           $error .= '<p> file bigger php installation allows</p>';           break;      case 2:           $error .= '<p> file bigger form allows</p>';           break;      case 3:           $error .= '<p> part of file uploaded</p>';           break;      case 4:           $error .= '<p> no file uploaded</p>';           break;  default:     $error .= '<p>'.$_files['infilename'] ['error'].'</p>';     break;  }   } echo $error;  //close database connection mysql_close($conn); 

any appreciated!

i think might looking 1 of following:

curl

run curl commands windows console

http://howes-it-going.com/curl_windows_example.html

how post put request under windows using curl?

send/post xml file using curl command line

soap / rest

representational state transfer (rest) , simple object access protocol (soap)

soap third-party:

winbatch - commercial, excellent support

autohotkey - free, not-so-hot support

biterscripting - unknown

in particular, think might find in curl dos, or via cygwin windows (which provides better curl implementation).


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -