So, I'm trying to check if the directory is not there, if it is, check for the file, if the file is there too, do the next one...but right now, something funky is happening, it's only evaluating for truth on the dir/file for existence, and the 2nd and successive times through, it's skipping that part of the loop. Any ideas on where the goof up is ??? Perl script follows
[perl]
#!/usr/bin/perl
#use strict;
use Net::FTP;
#declare global login etc variables
my $login;
my $password;
my $basepath;
my $file;
my $datadir;
my $dot1;
my $dot2;
my $server;
my $path;
my $mkd;
my $f;
my $ftp;
my $filename;
my @site;
my $fileinsite;
my $initial;
$login = "";
$password = "";
$server = "";
$basepath = "home/www";
$datadir = "";
$f = "";
$filename = "";
$mkd = "";
opendir(THEDIR, "$datadir") ¦¦ die ("Could not open the datadir: $datadir");
@site = readdir(THEDIR);
closedir(THEDIR);
$dot1 = shift(@site);
$dot2 = shift(@site);
my $ftp = Net::FTP->new("$server") or warn $ftp->message;
if ($ftp->login("$login","$password")) {
print "Logged into $server\n"; }
else { print "can\'t login ";
$ftp->quit();
return 0; }
$ftp->cwd("$path/");
$ftp->cwd("./www");
$ftp->put("practice/spider.txt");
$ftp->put("practice/.htaccess");
foreach $f (@site) {
$filename = $f;
if ($f =~ /\.html/) {
$ftp->put("practice/1/$f");
$ftp->quot('site chmod 0755',$f); }
else {
print "dir will be $f\n"; }
if ($ftp->cwd("$f")) {
print "$f already there, checking file $f\n";
@isthere = $ftp->ls($f);
if (@isthere =~ /index/) {
print "$f slash index already exists\n";
}
else {
$mkd = $ftp->mkdir("$f") or warn $ftp->message;
print "ok\n";
print "dir is $f\n";
$ftp->cwd("$f");
$ftp->put("practice/1/$f/index.html") or warn $ftp->message;
$index = "index.html";
$ftp->quot('site chmod 0755',$index);
$ftp->cwd("..");
sleep(2);
}
}
$ftp->quit();
print "Done...\n";
}
1;
[/perl]
I'll give that one a try if what I'm about to do doesn't work out...I figured out that the script didn't move back out of the directory it was checking when searching to see if the @isthere was true or false...
After I fix that, I'll check out your idea :) thanks.