Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7412427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:32:18+00:00 2026-05-29T06:32:18+00:00

After figuring out (via SO, of course) that the error for a bad $ftp

  • 0

After figuring out (via SO, of course) that the error for a bad $ftp = Net::FTP->new() call is in $@ while subsequent errors can be obtained by $ftp->message(), I’m striking a small problem.

My code is basically:

while (1) {
    # Wait for cycle start, then get file list into @filelist.

    foreach $file (@filelist) {
        my $ftp = Net::FTP->new ($host);
        if (! $ftp) {
            logError ("Could not connect to host [$host]: $@");
            return;
        }
        # More FTP stuff below with $ftp->message() error checking.
        $ftp->quit();
    }
}

Aside: yes, I know I can probably do this in one FTP session, but there are good reasons for leaving it in separate sessions at the moment.

Now this is being called in a loop, once per file, all going to the same host, but I’m getting a slightly different behaviour on the first attempt in most cycles. The script is a long-running one, with each cycle starting on the hour and half hour so it’s not some issue with the first ever attempt after program start, since it happens on cycles other than the first as well.

Now I know that these connections should fail, simply because the machines I’m trying to access are not available on my development network.

The trouble is that the errors coming out in the log file are:

E 2012-02-05 18:00:13 Could not connect to host [example.com]: 
E 2012-02-05 18:00:13 Could not connect to host [example.com]:
    Net::FTP: connect: Connection refused
E 2012-02-05 18:00:14 Could not connect to host [example.com]:
    Net::FTP: connect: Connection refused

As you can see, the $@ variable seems to be not populated the first file of the cycle. I’ve edited this question slightly since I’ve just noticed the latest cycle had all three lines with the error message. Going back over the logs with the command:

grep refused logfile | awk '{print substr($3,1,5)}' | uniq -c

to get the dates and counts, turns up the following statistics:

  3 11:00
  3 11:30
  3 12:00
  3 12:30
  3 13:00
  3 13:30
  2 14:00
  3 14:30
  3 15:00
  3 15:30
  3 16:00
  2 16:30
  2 17:00
  2 17:30
  2 18:00
  2 18:30
  2 19:00
  3 19:30

indicating that some have the correct count of error messages but not all.

I’m wondering if anyone knows why this may be the case.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:32:19+00:00Added an answer on May 29, 2026 at 6:32 am

    Try upgrading http://cpansearch.perl.org/src/GBARR/libnet-1.22_01/Changes says

    libnet 1.22_01 -- Mon May 31 09:40:25 CDT 2010
    *Set $@ when ->new returns undef
    

    If you’re using a version of libnet prior to 1.22_01, it had a small bug in the new function in regards to responses that didn’t start with a code.

    For example, FTP.pm 2.77 which is from libnet 1.21 has the following snippet:

    unless ($ftp->response() == CMD_OK) {
        $ftp->close();
        $@ = $ftp->message;
        undef $ftp;
    }
    

    With FTP.pm 2.77_2 from libnet 1.22_01, this is changed to:

    unless ($ftp->response() == CMD_OK) {
        $ftp->close();
        # keep @$ if no message. Happens, when response did not start with a code.
        $@ = $ftp->message || $@;
        undef $ftp;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update: Question updated after figuring out what was causing the ASP.NET/Razor errors. I have
Question: Can I override default functions in Javascript? Background: After figuring out that I
I'm having trouble figuring out how to maintain my table stripes after adding new
I am having trouble figuring out how to 're-render' a page after a POST
Even after studying the examples , I'm having trouble figuring out how to extract
After switching to AS3, I've been having a hell of a time figuring out
Having some trouble figuring out why my ImageView buttons stop working after I change
I need help with figuring out how to get hold of the redirect after
I am having trouble figuring out how to set arrays, on pageload, that contains
I edited this after figuring out a few things but is this a good

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.