Hi

I am trying to ftp files from a windows server to a unix machine. When I login with the required credentials into the windows server , I want to make sure that the login directory is the correct one else I should change directory before initiating the ftp process.
I am using a perl script for ftping the files.
Please help.

Regards
Debangana

Dani AI

Generated

Short summary and practical plan based on the thread: observed that the server reports the login directory as “/”, which is common on many Windows FTP setups. ’s suggestion to inspect directory contents is on the right track, and is also correct that server-side configuration usually determines the effective FTP root. Because many Windows FTP servers present a virtual FTP root for security, the protocol-level PWD response can be meaningless for mapping to a physical filesystem path.

Reliable checks to perform from the Perl script:

  • Treat the FTP-reported current-directory string as unreliable on Windows FTP servers.
  • Attempt to change to the expected subdirectory and check the FTP response code; a successful change is a stronger signal than the reported path.
  • Verify the presence of one or more known files (using size or timestamp commands) in that directory to confirm it is the intended location.
  • Turn on passive mode and module debugging while testing so the server responses and return codes are visible.

Example Perl pattern (using the Net::FTP API) that avoids relying on the reported PWD and verifies content:

use Net::FTP;
my $ftp = Net::FTP->new($host, Timeout => 30, Passive => 1) or die $@;
$ftp->login($user,$pass) or die "login failed";
if ($ftp->cwd('/expected/subdir')) {
  my $sz = $ftp->size('marker_file.txt');   # undef if not present
  die "directory not as expected" unless defined $sz;
}
$ftp->quit;

If the script still fails to find the expected files, inspect the FTP server configuration (user isolation/virtual-directory mappings) or the server logs so the administrator can confirm which physical folder is mapped to the FTP user. The Net::FTP docs and the FTP protocol specification are useful references: Net::FTP documentation and RFC 959 (FTP).

Recommended Answers

All 4 Replies

get the name of the directory after you login, see the documentation for the FTP module you are using for details.

Hi

I have tried using
[ftp->pwd]
to get the name of the current directory after I login but on windows server it always shows '/' as the login directory so I am not able to verify if it's the correct one.

Please help.

Regards
Debangana

Assuming you are using NET::FTP, look at the ls() or dir() functions and see if one of them will work.

i think you shouldn't need to worry too much on whether its the correct directory because you would have set it properly when configuring your FTP server.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.