I put in "or die $ftp->message();" and got the error "Invalid number of arguments." the next time it died.
Then I added "debug => 1" and... the script worked. And it worked the next 5 times I tried it. Note that I never changed the number of arguements... It just suddenly went from invalid to valid, automagically.
I shall meditate upon this.
This morning I noticed that the script did not work when cron called it in the middle of the night. I ran it again, and here are the two different debug outputs:
When the script works
Net::FTP=GLOB(0x8244e84)>>> TYPE binary
Net::FTP=GLOB(0x8244e84)<<< 500 'TYPE binary'
Net::FTP=GLOB(0x8244e84)>>> PORT 192,168,0,10
Net::FTP=GLOB(0x8244e84)<<< 200 PORT command
Net::FTP=GLOB(0x8244e84)>>> STOR howllog.html
Net::FTP=GLOB(0x8244e84)<<< 150 Opening ASCII
tml.
Net::FTP=GLOB(0x8244e84)<<< 226 Transfer comp
Net::FTP=GLOB(0x8244e84)>>> QUIT
Net::FTP=GLOB(0x8244e84)<<< 221 Goodbye.
When it doesn't work
Net::FTP=GLOB(0x8244e84)>>> TYPE binary
Net::FTP=GLOB(0x8244e84)<<< 500 'TYPE binary' not understood.
Net::FTP=GLOB(0x8244e84)>>> PORT 192,168,0,10,222,129
Net::FTP=GLOB(0x8244e84)<<< 501 Invalid number of arguments.
So my questions are two-fold:
1) Why is "TYPE binary" sometimes not recognized?
2) How can I get my perl to keep trying until the send is successful?
Now I have seen a
third output:
Net::FTP=GLOB(0x8244e84)>>> TYPE binary
Net::FTP=GLOB(0x8244e84)<<< 500 'TYPE binary' not understood.
Net::FTP=GLOB(0x8244e84)>>> PORT 192,168,0,10,223,46
Net::FTP=GLOB(0x8244e84)<<< 200 PORT command successful.
Net::FTP=GLOB(0x8244e84)>>> STOR howllog.html
Net::FTP=GLOB(0x8244e84)<<< 150 Opening ASCII mode data connection for howllog.html.
Net::FTP=GLOB(0x8244e84)<<< 226 Transfer complete.
Net::FTP=GLOB(0x8244e84)>>> QUIT
Net::FTP=GLOB(0x8244e84)<<< 221 Goodbye.
So obviously the success of "TYPE binary" has nothing to do with it. It's the PORT command that's killing me. When it failed, it said "invalid number of arguements", and we can clearly see 6 arguements were passed. In this last example there are 6 arguements as well, but the PORT was successful.
Back to my meditations
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.