#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Net::FTP put error - Array


    I'm am not a programmer by any means but I have used Perl to accomplish a few tasks in the past. At the moment I need a script to read file names from a file that I create from an 'ls' command. Then I need it to connect to a remote server and put those file(s) in the remote directory.

    When I run the script I get the following error:

    # ./ftp_logs2.sh
    Bad remote filename '20121221.log
    '
    at ./ftp_logs2.sh line 33

    I have checked the file that I create on line 8 and there are no spaces etc. Here is a sample for the 'filelist' file:

    20121221.log
    20121222.log
    20121223.log

    I have also included 'print' statements at times within the script to print the contents of the array and it seems fine. I'm not sure what I'm missing. It's such a simple script but......

    Here it is. Please don't kill me for lack of comments and
    indentation etc.

    #!/usr/bin/perl -w
    ########################################
    {
    chdir("/var/log/wireless");
    system ("find \*.log -type f -mtime +1 >>filelist");
    $userid = "memorial\\cw2000";
    $password = "g0ldfing3r";
    $list = "/var/log/wireless/filelist";
    open("list");
    @array = <list>;
    close("list");
    $file = shift(@array);
    do
    {
    use Net::FTP;
    $ftp = Net::FTP->new("10.9.80.38");
    $ftp->login("$userid", $password)
    or die "Cannot login ", $ftp->message;
    $ftp->ascii;
    $ftp->cwd("/wireless/syslog")
    or die "Cannot change working directory ", $ftp->message;
    $ftp->put($file);
    }
    until (@array eq 0);
    $ftp->quit;
    }
    system ("rm -f /var/log/wireless/filelist");
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    837
    Rep Power
    496
    Originally Posted by mpride
    Please don't kill me for lack of comments and
    indentation etc.
    As I told you in your cross-post in Perl Gurus, why should we want to kill you for that? No point, really. You are shooting the bullet into your head yourself, you don't need any help for your suicide, you're doing it yourself very properly and very efficiently...

    For more detailed comments on your code, please refer to the post in the Perl Gurus forum.

IMN logo majestic logo threadwatch logo seochat tools logo