View Single Post
Old 01-25-2005, 08:50 PM   #7 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,490
sde is on a distinguished road
well if you have to install something, and you already know a bit of php, then maybe php would be the choice. you can run php scripts in the window shell.

php usually installs in: C:\php

let's say we wrote a script to upload the csv file, and then call the php script on the remote server that will parse and write data to the db. let's say we named this script: update.php and for this example it is located in C:\scripts\update.php

once php is installed on your windows box, you can call the script from a windows shell like this:
Quote:
c:\php\php.exe c:\scripts\update.php
now, a quick search on php.net turned up the ftp logic, .. i just added one extra function at the bottom to call the csv_parser script on the remote server. this will probably work as is if you go this way. you may just need to make a bat script with the code to call the php program.
PHP Code:
<?
$source_file 
"C:\\directory\\to\\file.csv";
$destination_file "path/to/file.csv";
$ftp_server "mydomain.com";
$ftp_user_name "me";
$ftp_user_pass "pass";


// set up basic connection
$conn_id ftp_connect($ftp_server);

// login with username and password
$login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);

// check connection
if ((!$conn_id) || (!$login_result)) {
       echo 
"FTP connection has failed!";
       echo 
"Attempted to connect to $ftp_server for user $ftp_user_name";
       exit;
   } else {
       echo 
"Connected to $ftp_server, for user $ftp_user_name";
   }

// upload the file
$upload ftp_put($conn_id$destination_file$source_fileFTP_BINARY);

// check upload status
if (!$upload) {
       echo 
"FTP upload has failed!";
   } else {
       echo 
"Uploaded $source_file to $ftp_server as $destination_file";
   }

// close the FTP stream
ftp_close($conn_id);

// call the php csv parser file
file("http://mydomain.com/parse_csv.php");
?>
__________________
Mike
sde is offline   Reply With Quote