namishtiwari has asked for the wisdom of the Perl Monks concerning the following question:
I am not getting the desired results as the files are not copied,am i missing anything here. It prints these lines--#!/usr/bin/perl use Net::FTP; my $host="abc.def.com"; my $directory="/namish/logs/nali05/"; $ftp=Net::FTP->new($host,Timeout=>240) or $newerr=1; push @ERRORS, "Can't ftp to $host: $!\n" if $newerr; myerr() if $newerr; print "Connected\n"; $ftp->login("abcd","hi1234\@") or $newerr=1; print "Getting file list"; push @ERRORS, "Can't login to $host: $!\n" if $newerr; $ftp->quit if $newerr; myerr() if $newerr; print "Logged in\n"; $ftp->cwd($directory) or $newerr=1; push @ERRORS, "Can't cd $!\n" if $newerr; myerr() if $newerr; $ftp->quit if $newerr; @files=$ftp->dir or $newerr=1; push @ERRORS, "Can't get file list $!\n" if $newerr; myerr() if $newerr; print "Got file list\n"; foreach(@files) { print "$_\n"; } $ftp->quit; sub myerr { print "Error: \n"; print @ERRORS; exit 0; }
Kindly give your valueable suggestions. I want to clear what exactly i am doing here.. I wrote the above perl script to get the files in a specifed directory called temp. The files which i get all are zipped ones. I want to unzip all the files and choose some which of my interest and delete rest of the files. I achieved the first part but i am struglling for the second. The files which i am getting after ftp are like this-- tali05_Jul122009_2358.zip tali05_Jul122009_4567.zip tali05_Jul122009_9876.zip I want to unzip all these files after getting them. When we unzip these files we get files like-- nt123_12Jul09_13_05_23.log ntrf_12Jul09_14_35_33.log and many more like this.. I want to keep only the first one and delete the second file. Kindly help me in achieving this. Thanks NT Reply With Quote Thanks NTRETRIEVING AOK LOG FILES FROM LOG.ARCOT.COM...... Connected Getting file listError: Can't login to abc.def.com:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ftp issue in perl
by Corion (Patriarch) on Jul 27, 2009 at 07:36 UTC | |
by namishtiwari (Acolyte) on Jul 27, 2009 at 08:54 UTC | |
by ig (Vicar) on Jul 27, 2009 at 09:25 UTC | |
by mzedeler (Pilgrim) on Jul 27, 2009 at 09:33 UTC | |
|
Re: ftp issue in perl
by cdarke (Prior) on Jul 27, 2009 at 07:41 UTC | |
by namishtiwari (Acolyte) on Jul 27, 2009 at 09:37 UTC | |
by marto (Cardinal) on Jul 27, 2009 at 09:58 UTC | |
by namishtiwari (Acolyte) on Jul 27, 2009 at 10:36 UTC | |
by Corion (Patriarch) on Jul 27, 2009 at 10:44 UTC | |
by roboticus (Chancellor) on Jul 27, 2009 at 19:04 UTC | |
|
Re: ftp issue in perl
by apl (Monsignor) on Jul 27, 2009 at 11:32 UTC | |
|
Re: ftp issue in perl
by Selvakumar (Scribe) on Jul 27, 2009 at 10:58 UTC | |
by namishtiwari (Acolyte) on Jul 27, 2009 at 11:32 UTC |