[EMAIL PROTECTED] wrote:
> I am trying to modify a script to
> automatically login to an FTP server

use Net::FTP;

  my $ftp = Net::FTP->new('ftp.server.domain.com');
  $ftp->login('username', 'password');

> and LCD to a path

This is nothing to do with FTP: you just need to change
your local working directory liek this

  chdir('/a/path');

> and then CD to the path where the files are

  $ftp->cwd('/path/where/files/are');

> then to download the files.

  $ftp->get('the.files');

> I wrote this in DOS about 6 months ago and it works in conjunction with a
> batch file (which calls the login/command file) but I am having problems
> porting it to perl.  I have tried using a system call to call the ftp
> program, but I can't get it to bring in the file.
>
> sub get_files
> {
>  system 'ftp','-f:.ftplog','10.1.1.48';
> }
>
> #.ftplog file
> ------------------
> login
> pass
> lcd /home/web/sales/info/
> cd /u/dsk/ipo
> pwd
> verbose
> prompt
> bin
> mget salesa*
> pwd
> quit

It looks like this should translate to something like the following, but the
'prompt' bit will prompt you for whether or not to get each file, and that
gets complicated because it's not straightforward even to tell whether a
name is a plain file, a link or a directory so I'm not going to write that for
you. With debug enabled you'll be able to see what it's doing, so run it that
way to see if it does what you want, and then you can disable debug and
uncomment the 'get' call and it should work for you.

HTH,

Rob




  use strict;
  use warnings;

  use Net::FTP;

  my $ftp = Net::FTP->new('10.1.1.48', Debug => 1);
  $ftp->login;

  chdir('/home/web/sales/info');

  $ftp->cwd('/u/dsk/ipo');

  print $ftp->pwd, "\n";

  my @files = grep /^salesa/, $ftp->ls;

  foreach (@files) {
    print "Getting $_\n";
#   $ftp->get($_);
  }




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to