in reply to script for accessing ftp servers

I installed FileZilla on my Win7 laptop to test this out for you. I ran the script from a Ubuntu VM. Note that I had to change some of the variables to make it work in my environment, so just change them back to what you had originally.

moritz was of course right about the FTP root directory. When you configure a user on your FTP server and set their 'shared directory' to "C:/Users/Win7/Desktop/intenship doc2/", you are automatically dropped into that directory when you log into the system via FTP. When I define the variable $directory in my code below, I specify I want to be in the root directory, which on the FTP server is the shared directory itself. I can not go up in the directory tree. If you print out $ftp->pwd() after you've logged in, you won't see the entire C:/Users... path at all.

In FileZilla I set up, I configured the 'stevieb' user with a 'shared directory' of C:/Users/steve/Desktop, and placed a file called 'blah.txt' there. Note in my code how I specify that I want to work in that directory. I've also fixed the code so that it is strict compliant (you should get in the habit of using 'use strict;' and 'use warnings;'

#!/usr/bin/perl use DBI; use Net::FTP; use File::Basename; use warnings; use strict; #connection paraneters to localhost my $IP='192.168.1.2'; my $users='stevieb'; my $password='blah'; my $directory="/"; #Connection to netboss my $ftp = Net::FTP->new($IP, Debug => 0, Passive => 0) or die "cannot +connect"; $ftp->login($users,$password); $ftp->cwd($directory); #list files my @fichier = $ftp->ls($directory); for my $entry (@fichier) { my $filename = basename( $entry ); if( $filename =~ "blah.txt" ){ # you'll need to uncomment the next line, and comment out # the one below it to return to your desired behaviour #$ftp->get($filename,"C:/users/Desk/personal".$filename); $ftp->get( $filename ); } } $ftp->quit;