Net::FTP and "mput" issue...cannot change local currently directory

From: John Davis (tudmuf2b_at_onebox.com)
Date: 01/30/04


Date: 30 Jan 2004 13:42:28 -0800

I'm trying to use the Net::FTP module in an "mput" like way, but it
does not seem to work correctly. I have a script that gets any number
of files from another server and put them in a directory called
"/tmp/dbinfo"

>From /tmp/dinfo, I want to mput all of those files that are in the
directory with the db.out attached to the name, and only those files.
So files such as acedb.out, testdb,out are good, etc.

>From my code below, it continues to say that files such as acedb.out,
testdb.out cannot be accessed. If that because the local currently
directory is not set right? I have a chdir (/tmp/dbinfo) - where the
files are, but it cannot put them onto the remote host.

I've moved the chdir around but without success...

Any ideas?

Thanks!

---------------------

#!/opt/perl/bin/perl -w

use strict;
use Net::FTP;
my ($hostname, $username, $password, $directory, $ftp, @last);
$hostname="dbmaster1";
$username="ftp";
$password="nothing";
$directory="/incoming";

my @filelist;
my $file;

chdir ("/tmp/dbinfo");

opendir (DIR, "/tmp/dbinfo") || die "Can't open: $! \n";
@filelist=readdir(DIR);
closedir(DIR);

$ftp=Net::FTP->new ($hostname);
$ftp->login($username, $password);
$ftp->cwd ($directory);

foreach $file (@filelist) {
  next if ! ($file=~/db.out/) ;
  $ftp->put("$file");
}
$ftp->quit;



Relevant Pages

  • Re: Question about system() in multiple threads
    ... I did some testing again on the script that I posted, ... Good point about that the chdir() may create a race condition. ... I don't think that *simply* adding a semaphore will help you, ... that wait will get its own background job rather than the other threads ...
    (comp.lang.perl.misc)
  • Re: Stat() function fails?
    ... >filenames, and people forget to apply the full path when using ... (start of script) ... "Couldn't chdir"; ... If it works on somebody else's setup and not mine I will probably give ...
    (comp.lang.perl.misc)
  • Re: Stat() function fails?
    ... "Joe Cosby" wrote in message ... > I'm trying to write a script which converts a directory to html, ... I'd guess the chdir is the culprit. ...
    (comp.lang.perl)
  • Re: Script Optimization
    ... I like using tabs because of the text editor I use, the script at ... Can't you configure it to use 4 spaces per indent - and not use "hard" tabs? ... keeping them in case the indentation is ever lost - makes it easy to ... to accomodate the functions - changed functions to not chdir as much), ...
    (comp.lang.python)
  • Re: Problems with chdir()
    ... >> I have a script that uses the chdir() function. ... >> The same script works at my personal host, ... > error message says, anyways. ...
    (comp.lang.php)