Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Perl FTP Error

Posted on 2005-04-11
6
Medium Priority
?
545 Views
Last Modified: 2013-12-05
Hello

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  = "192.168.0.1" ;
$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 some.host.name: $@";

$ftp->login("$uname","$pwd")
      or die "Cannot login ", $ftp->message;

$ftp->cwd("$dir")
      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 ... " ;


      $ftp->get("$file","$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" ;
      }
      
}

$ftp->quit;

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.

Thanks
0
Comment
Question by:PSOHEALTH_IS
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:aromberg
ID: 13756827
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?
0
 

Author Comment

by:PSOHEALTH_IS
ID: 13756874
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.
0
 
LVL 20

Expert Comment

by:jmcg
ID: 13757475
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.
0
 

Author Comment

by:PSOHEALTH_IS
ID: 13763414
I am actually trying it with the root user and I am having the problem. I haven't been able to figure it out.
0
 
LVL 20

Accepted Solution

by:
jmcg earned 0 total points
ID: 13783177
PAQ, 500 points of 500 refunded.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

572 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