M
Matt
Hello,
I am writing a script that opens needs to get a listing of files in a
directory, print that listing to a file and use that file as a quasi ftp
control file. My problem is that when I print the filenames found via the
readdir I also get the . and .. (current directory and parent directory)
written in the ftp control file which causes my script to stop since you
can't ftp . nor ..
Here's my logic ....
opendir(DON,"/don") || die "Can't opendir /don: $!";
open(DATFILELIST,">>/data/datafiles.out") || die "Can't opendir
/data/datafiles.out: $!";
print DATFILELIST "cd /incoming\n";
print DATFILELIST "lcd /data/utech/dat\n";
while ($donefile = readdir(DON)) {
$datafile = $donefile;
$datafile =~ s/\.don/\.dat/;
print DATFILELIST "get $datafile\n";
}
print DATFILELIST "bye\n";
close(DATFILELIST) || die "Can't close file /data/datafiles.out $!";
closedir(DON) || "Can't closedir /data/utech/don: $!";
The DATFILELIST gets the right files, but it also gets the . and .. which
causes the ftp to fail.
I wonder if my real problem is with my pattern matching. I want to match
all occurences of a file that ends in .don and rename the extension to .dat
then write that output to the DATFILELIST file. This works, but it also
includes the . and ..
Any ideas woud be much appreciated.
Thanks,
Matt
I am writing a script that opens needs to get a listing of files in a
directory, print that listing to a file and use that file as a quasi ftp
control file. My problem is that when I print the filenames found via the
readdir I also get the . and .. (current directory and parent directory)
written in the ftp control file which causes my script to stop since you
can't ftp . nor ..
Here's my logic ....
opendir(DON,"/don") || die "Can't opendir /don: $!";
open(DATFILELIST,">>/data/datafiles.out") || die "Can't opendir
/data/datafiles.out: $!";
print DATFILELIST "cd /incoming\n";
print DATFILELIST "lcd /data/utech/dat\n";
while ($donefile = readdir(DON)) {
$datafile = $donefile;
$datafile =~ s/\.don/\.dat/;
print DATFILELIST "get $datafile\n";
}
print DATFILELIST "bye\n";
close(DATFILELIST) || die "Can't close file /data/datafiles.out $!";
closedir(DON) || "Can't closedir /data/utech/don: $!";
The DATFILELIST gets the right files, but it also gets the . and .. which
causes the ftp to fail.
I wonder if my real problem is with my pattern matching. I want to match
all occurences of a file that ends in .don and rename the extension to .dat
then write that output to the DATFILELIST file. This works, but it also
includes the . and ..
Any ideas woud be much appreciated.
Thanks,
Matt