Hi Monks, Here is my piece of code--
#!/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; }
I am not getting the desired results as the files are not copied,am i missing anything here. It prints these lines--
RETRIEVING AOK LOG FILES FROM LOG.ARCOT.COM...... Connected Getting file listError: Can't login to abc.def.com:
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 NT

In reply to ftp issue in perl by namishtiwari

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.