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

Can anyone please tell me how to get the current working directory of the remote server using Net::FTP.

Thanks in advance.

Replies are listed 'Best First'.
Re: cwd of remote server using Net::FTP
by duff (Parson) on Dec 03, 2004 at 04:59 UTC

    From perldoc -f Net::FTP:

    pwd ()
               Returns the full pathname of the current directory.
    

    Surely you've searched the docs? That entry is just a little bit down from the entry on cwd

      I tried pwd(). It is returning '/'. my script is as follows.
      use Net::FTP; $ftp = Net::FTP->new("Ram", Debug => 0) or die "Cannot connect to some.host.name: $@"; $ftp->login("anonymous",'-anonymous@') or die "Cannot login ", $ftp->message; $temp = $ftp->pwd(); print "test\n", $temp ; #$ftp->get("test.txt") #' or die "get failed ", $ftp->message; $ftp->quit;
      Thanks & Regards

      Nalina

        Net::FTP behaves in the same way as your command line ftp. I bet that, if you ftp from command line to the same site, then issue a pwd command, you will get the same thing, the root.

        So this is not a problem with Net::FTP module, but rather the server is configured in this way, and that was what you supposed to get. I tried to ftp ftp.sun.com, that was what I got.

        However this is not always what you get. When I try to ftp to a UNIX node on your company's network that I have account, I was led to my home directory.

Re: cwd of remote server using Net::FTP
by NetWallah (Canon) on Dec 03, 2004 at 05:41 UTC
    Aah - it looks like what you are asking for is the ABSOLUTE path to the working directory.

    Sorry - no can do via FTP - that would be a security hazard.

    What you are getting is the relative path, which is the FTP root, or "/".

        ...each is assigned his own private delusion but he cannot see the baggage on his own back.

Re: cwd of remote server using Net::FTP
by Mago (Parson) on Dec 03, 2004 at 19:42 UTC

    Net::FTP - FTP Client class


    pwd ()
    Returns the full pathname of the current directory.