Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: NET::ftp mkdir succeeds but then dies with 501?

by philipbailey (Chaplain)
on May 08, 2009 at 08:33 UTC ( #762776=note: print w/replies, xml ) Need Help??

in reply to NET::ftp mkdir succeeds but then dies with 501?

(Reply removed)
  • Comment on Re: NET::ftp mkdir succeeds but then dies with 501?

Replies are listed 'Best First'.
Re^2: NET::ftp mkdir succeeds but then dies with 501?
by rjc_thatsthat (Initiate) on Mar 01, 2010 at 15:10 UTC
    Just to update - I had to revisit this block of code recently with slightly more experience. Wrapping the code in an eval and viewing the resulting $@ revealed that the mkdir was in fact firing twice in immediate succession, producing the 501 error on the second attempt.
    $ftp->cwd($i2) or die "change directory $i2: ".$ftp->message." / ".$ft +p->code; my @nfiles = $ftp->dir; if(grep {$_ eq $i3} @nfiles){ die "make $i3: already exists"; } else { $ftp->mkdir($i3) or die "make directory ".$ftp->code; }
    Although still not obvious to me exactly where, it looks like code elsewhere was looping over the mkdir without being caught, so I rewrote, removing the eval/dies, which seems to behave as expected.
    push @errs,"cannot change directory from $ftp->pwd to i2: $ftp->messag +e" unless $ftp->cwd($i2); my @nfiles = $ftp->dir; push @errs,"cannot list directory $ftp->pwd: $ftp->message" unless @nf +iles; push @errs,"directory $n2 already exists in $ftp->pwd: $ftp->message" +if grep {$_ eq $n2} @nfiles; push @errs,"cannot make directory $n2 in $ftp->pwd: $ftp->message $ftp +->code" unless $ftp->mkdir($n2); $ftp->quit; if(@errs){ print join "<br />",@errs; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://762776]
[marto]: and this is a bank you say?
[hippo]: Yary: There are a few useful pointers in I need perl coding standards
[hippo]: ... and a boatload of good stuff in On Coding Standards and Code Reviews
[Yary]: Looking at system pm's, looks like it's "package" on the first line, then POD, then "use;use strict; use warnings; use modules..."
[Yary]: ah thanks for those links
[hippo]: Just bear in mind that all such ideas are subjective.
[choroba]: There might be a different standard at the shop you write the code for.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2018-01-23 16:58 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (250 votes). Check out past polls.