I had to do a similar thing several months ago - copy a database file from one Windows box to another using a script on a Sun server. Here's my solution...
#! /usr/bin/perl
#
# Program: mv_mdb_files.pl
# Author: Jack Coxen <Jack.Coxen@TelCove.com>
#
# Orig: July 22, 2005
# Purpose: Move Access .mdb files from "\\svr1\source_share\sourc
+e_dir\Database.mdb"
# to "\\svr2\dest_share\dest_dir\Database.mdb"
#
# Default use statements
use strict;
use warnings;
#use diagnostics; # Uncomment this for development ONLY!!!
# Other use statements
use Filesys::SmbClientParser; # Perl client to reach
+ Samba resources with smbclient
use Net::SMTP; # Simple Mail Transfer
+ Protocol Client
# Set DEBUG Messages on or off
my $DEBUG = 0;
our $src;
# Setup variables
my $recipient = "name\@company.com"; # Mail recipient
my $admin = "admin\@company.com"; # Administrator
my $now = gmtime; # Grab the current tim
+e
# Setup smbclient
my $smb_src = new Filesys::SmbClientParser;
$smb_src->Auth("/usr/local/cap-files/Master/.smbpw-svr1");
$smb_src->Host("svr1_name");
$smb_src->Share("share_name");
my $smb_dest = new Filesys::SmbClientParser;
$smb_dest->Auth("/usr/local/cap-files/Master/.smbpw-svr2");
$smb_dest->Host("svr2_name");
$smb_dest->Share("share_name");
# Setup the SMTP client
my $smtp = Net::SMTP->new(
Host => 'mail_svr.company.com',
Timeout => 30,
Debug => $DEBUG,
);
#
# Main Program
#
# Copy files from $smb_src to $smb_dest
print "cd source_dir\n" if $DEBUG;
$smb_src->cd('source_share\\source_dir')
or die "Cannot execute cd source_dir", $smb_src->err;
print "Copying Database.mdb from svr1\n" if $DEBUG;
$smb_src->get('Database.mdb')
or die "Cannot get file", $smb_src->err;
print "cd dest_dir\n" if $DEBUG;
$smb_dest->cd('dest_share\\dest_dir
or die "Cannot execute cd dest_dir", $smb_dest->err;
print "Copying Database.mdb to svr2\n" if $DEBUG;
$smb_dest->put ('Database.mdb')
or die "Cannot put file", $smb_dest->err;
# Email a run notification to $recipient and cc $admin
$smtp->mail('script_owner@company.com');
$smtp->recipient($recipient,$admin, {SkipBad => 1});
$smtp->data();
$smtp->datasend("To: $recipient\n");
$smtp->datasend("CC: $admin\n");
$smtp->datasend("Date: $now\n");
$smtp->datasend("From: Script Owner\n");
$smtp->datasend("Subject: mv_mdb_files.pl\n");
$smtp->datasend("\n");
$smtp->datasend("mv_mdb_files.pl was executed at $now\n\n");
$smtp->datasend("The file \"Database.mdb\" was copied from\n");
$smtp->datasend("\\\\svr1\\source_share\source_dir to\n");
$smtp->datasend("\\\\svr2\\dest_share\dest_dir\n\n");
$smtp->datasend("Please verify that the file copied correctly\n");
$smtp->datasend("\n");
$smtp->datasend("Please report any problems to $admin\n");
$smtp->dataend();
$smtp->quit;
Set this up as a cron job to run whenever. It'll email an "I ran, make sure I ran right" message to you or whoever when it's done. This was just a quick fix I hacked together so I didn't put any serious error checking into it - 'course my 'quick fix' has been running for almost a year now so maybe I should go back and clean things up <adding that to my ToDo List>. ;)
Jack