Perl FTP Error

Posted on 2005-04-11
Last Modified: 2013-12-05

I am running a Perl Script to upload information that I have on a unix box on a daily basis. This script was previously working when I upload from SCO 5.0.5. I have now upgraded to a new Unix box running SCO Openserver 5.0.7. Whenever I run this script it give me an error on the "ls" command. The error that it puts out is "Argument too long". Has anybody every received the type of error. Can someone please point me in the right direction. I would greatly appreciate it.

Here is a copy of the script:

use Net::FTP;

$ip  = "" ;
$dir = "\/usr2/dataset1" ;
$uname = "abc" ;
$pwd = "abc" ;
$locFile = "f:\\e\\dsa\\test\\rawdata\\" ;

$log = ">>logfile.txt" ;
open(FF,"$log") ;

$dt = gmtime() ;

print FF "$dt\n" ;
print FF "----------------------------------\n" ;

$ftp = Net::FTP->new($ip, DEBUG => 0)  
      or die "Cannot connect to $@";

      or die "Cannot login ", $ftp->message;

      or die "Cannot change working directory ", $ftp->message;

@files = $ftp->ls   ----------------------------------------> here is where I get the error.
      or die "list failed: ", $ftp->message;

$success = 0 ;
$failure = 0 ;
foreach $file (@files) {

      next unless $file =~ /\.dme|\.dat/gi ;

      $dfile = $file ;
      $dfile =~ s/\.dme/\.dat/g ;

      $dest = $locFile.$dfile ;

      print FF "Copying $file to $dest ... " ;
      print "Copying $file to $dest ... " ;

       or die "get failed ", $ftp->message;

      if (-e $dest) {
            $success++ ;
            print FF "OK\n" ;
            print "OK\n" ;
      } else {
            $failure++ ;
            print FF "FAILED!\n" ;
            print "FAILED!\n" ;


print FF "-------------------------------\n";
print FF "Successfully copied $success files\n";
print FF "Failed to copy $failure files\n";
print FF "-------------------------------\n\n" ;
close(FF) ;

any help is appreciated.

Question by:PSOHEALTH_IS
    LVL 4

    Expert Comment

    Normally when you get argument too long, that means there is too many files for your ftpd to handle, have you tried clearing out that directory or uploading to a different one?

    Author Comment

    I have. But the only issue that I have with that is due to the fact that I just upgraded this system on the weekend. It is the same information that I was downloading on my previous server. An exact copy are on both machines. If I run this script on my previous unix box the script works great, but on the new one it crashes everytime.
    LVL 20

    Expert Comment

    The ftp 'ls' command is often implemented by running an actual command named 'ls' on the remote host. I would check to see whether there is a difference between the 'ls' command that is run for user 'abc' on the old host vs the new host. If someone has introduced a more "user-friendly" command in place of the basic 'ls' command, for instance, it could mess up when called in the context of that same user logged in via FTP. Aside from this hint, I'm not sure what else could account for the difference in behavior that you've seen.

    Author Comment

    I am actually trying it with the root user and I am having the problem. I haven't been able to figure it out.
    LVL 20

    Accepted Solution

    PAQ, 500 points of 500 refunded.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
    I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now