ism has asked for the wisdom of the Perl Monks concerning the following question:

Hello everybody!


I really stuck with this question. It seemed there was similar question was discussed here (http://www.perlmonks.org/?node_id=182444). But i don't found solution there. So i need help with that.


I'm using Net::FTP

Here is sample of code that i'm using
my $ftp_dir_base = '\Folder\Somefolder\ONE TWO Three\_Some_Path\ONE TW +O Three Path1'; my $ftp_dir0 = "\Folder\Somefolder"; my $ftp_dir1 = "ONE TWO Three"; print "CWD to: $ftp_dir0\n"; $ftp->cwd($ftp_dir0) or die "Can't go to $ftp_dir0: $!"; print "CWD to: $ftp_dir1\n"; $ftp->cwd($ftp_dir1) or die "Can't go to $ftp_dir1: $!";
I get error message: Can't go to 'ONE TWO Three': at ...etc.

I tryed with:
my $ftp_dir1 = "\"ONE TWO Three\""; my $ftp_dir1 = 'ONE TWO Three'; my $ftp_dir1 = '"ONE TWO Three"'; my $ftp_dir1 = "ONE\ TWO\ Three"; $ftp->cwd('ONE TWO Three') or die "Can't go to $ftp_dir1: $!";
...and some others variants

But nothing is worked. Can you help me with this?

Replies are listed 'Best First'.
Re: CWD to directory which name contain spaces
by RedElk (Hermit) on Aug 27, 2012 at 16:33 UTC

    In your code try CD in place of CWD.

Re: CWD to directory which name contain spaces
by aitap (Curate) on Aug 28, 2012 at 13:22 UTC
    Are you sure you shouldn't be using forward slashes (/) instead of backward slashes (\)?
    Sorry if my advice was wrong.
Re: CWD to directory which name contain spaces
by philiprbrenan (Monk) on Aug 30, 2012 at 07:42 UTC

    If this is till a problem, please turn on debug mode for FTP:

    my $f = Net::FTP->new("ftp.xxxx.com", Debug=>1);

    or print the response after each call:

    say $f->message;

    this will help us help you.

Re: CWD to directory which name contain spaces
by remiah (Hermit) on Aug 27, 2012 at 12:43 UTC

    If it is Microsoft, How about "One TW~1" ?
    like "Progra~1" works on windows instead of "Program Files"?

      Thank you for your answer! Unfortunately it also doesn't work for me. I really don't understand what happening. When i try perform the same commands in cli like:

      ftp> cd "/Folder/Somefolder/ONE TWO Three/_Some_Path/ONE TWO Three Pat +h1"
      everything is ok. directory is changing. But execution the same commands through script doesn't work.

        Do you see something when you set Debug level higher?

        $ftp = Net::FTP->new("some.host.name", Debug => 0) or die "Cannot connect to some.host.name: $@";