- 论坛徽章:
- 0
|
#!/usr/bin/perl -w
use strict;
our $WORK_DIR = $ARGV[0] . '/test';
our $SAVE_DIR = $ARGV[0] . '/saved';
&ReadDir($WORK_DIR);
if ( -d $SAVE_DIR/$part_path)
{
print $SAVE_DIR/$part_path;
}
else
{
print "hehe";
}
sub ReadDir
{
my ($dir) = @_;
opendir(DIR, $dir);
print $dir,"\n";
foreach my $element (readdir(DIR))
{
my $full_path = "$dir/$element";
if ('.' eq $element || '..' eq $element) { next; }
print $full_path,"\n";
print "1111111","\n";
if (-d $full_path)
{
print "directory".$full_path,"\n";
&ReadDir($full_path);
}
else
{
print "not directory","\n";
print "full_path=",$full_path,"\n";
my $partical_path = substr($full_path,29);
print "partical_path=",$partical_path,"\n";
our $part_path = substr($partical_path,0,rindex($partical_path,'/')+1);
print "part_path=",$part_path,"\n";
my $txtfile_dir = substr($full_path,0,rindex($full_path,'/')+1);
print $txtfile_dir,"\n";
my $call_unix = "cp $txtfile_dir/*.txt /ouc/oucdev/adm/ftp/cws/test2/";
system($call_unix);
}
}
closedir(DIR);
} |
|