#How do I name the absolute path?
my $sourceFile = "C:\\webServer\\myfile.doc";
my $destinationFile = "\\\\myInfoServer\\dirOne\\";
system("copy $sourceFile $destinationFile > nul") == 0 || die "File did not copy: $!";
#will change the copy command to cp when I put it on Unix
Please advise.
How can I find the File (myfile) from the Unix server? I know I cant call it what it currently is -> C:\\webServer\\myfile.docDepends entirely on your network config ... does the windows box share that directory? does the unix server mount it? is there another way to pull off the file (e.g. ftp or http)? This question really needs to be directed at the administrator of that specific windows server.
1) File::Spec (makes using path info easier).
2) File::Copy (use Perl copy rather than making a system call.
3) To send a file to Unix, you might want to look at something like Net::FTP and use FTP to transfer the file from one platform to the other.
On the other hand,
#! /usr/bin/perl # # Program: mv_mdb_files.pl # Author: Jack CoxenSet 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# # Orig: July 22, 2005 # Purpose: Move Access .mdb files from "\\svr1\source_share\source_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 time # 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;
Jack
perlmonks.org content © perlmonks.org and Anonymous Monk, davidrw, ikegami, jcoxen, nimdokk
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03