Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test if file exists on remote computer

Status
Not open for further replies.

bubudush

Programmer
Oct 7, 2008
1
CA
Hi,

The following part of the script works when run manually. When triggered automatically (by ftp upload) the remote directory is not recognized. Please let me know what I am doing wrong.

Because the folder is not found the zipfile created is empty.

sub createimgzip
{
$in=$_[0];
$zp=$_[1];
$dt6=$_[2];
$dbcd=$_[3];

chomp($in);

$dbcd2=uc($dbcd);

$remdir="$dbcd\\$dbcd2$dt6"."IDL2";

$imgdir="\\\\FileServer\\DC_Images\\$remdir";


$c=0;
$pat1='\[';
$pat2='.*?txt';

use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
my $zip = Archive::Zip->new();

open (IN,"$in");
while(<IN>)
{
if ($_=~m/($pat1)($pat2)/g)
{
if (-e "$imgdir\\$2") {$c++;my $file_member = $zip->addFile("$imgdir\\$2", $2);}
next;
}

}

unless ( $zip->writeToFileNamed("$zp") == AZ_OK ) {
die 'couldn\'t zip';
}
close(IN);
}
 
Using mapped drives is a complete pain. I find it's best to map them then unmap them when finished for every script.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top