Create Directory, 'cd' to it and download a file pipeline in Perl
- by neversaint
I have a file that looks like this:
ftp://url1/files1.tar.gz dir1
ftp://url2/files2.txt dir2
.... many more...
What I want to do are these steps:
Create directory based on column 2
Unix 'cd' to that directory
Download file with 'wget' based on column1
But how come this approach of mine doesn't work
while(<>) {
chomp;
my ($url,$dir) = split(/\t/,$_);
system("mkdir $dir");
system("cd $dir"); # Fail here
system("wget $url"); # here too
}
What's the right way to do it?