deadpickle has asked for the wisdom of the Perl Monks concerning the following question:

I keep getting this error when I call: $ftp->move("$nick.bak","$nick") or die $ftp->message;
Use of uninitialized value $t in length at C:/camelbox/site/lib/Net/FT +P/File.pm line 128. Thread 2 terminated abnormally: write($buf,$size,[$timeout]) at C:/cam +elbox/site /lib/Net/FTP/File.pm line 128 thread 2
I am not sure what is going on here. The variable $nick is correct and print $ftp->pwd(),"\n"; return a correct value. Any ideas?

Below I also included the subroutine in the program that uses this call, just in case.

sub ftp{ my @list; my $new_dir2; my $count = 0; my $dir = cwd; my @new_dir1 = split('/',$dir); foreach my $kid (@new_dir1){ $new_dir1 .= "$kid\\"; $new_dir2 .= "$kid\\"; } $new_dir1 .= "gps"; $new_dir2 .= "icons"; $img_met = "$new_dir2\\met.png"; $img_spoton = "$new_dir2\\spoton.png"; $img_spotoff = "$new_dir2\\spotoff.png"; $img_spotdis = "$new_dir2\\spotdis.png"; $|++; while(1) { if ( $die == 1 ){ goto END }; #~ print "$sftp_start\n"; if ( $sftp_start == 1) { my $ftp = Net::FTP->new("updraft.unl.edu", Passive => 0) o +r $error = 1; if (defined($ftp)){ if ($special == 1){ $special = 2; } $ftp->login("*****",'*****') or $error = 1; eval{$ftp->cdup or $error = 1;}; eval{$ftp->cwd($gps_remote) or $error = 1;}; for (;;) { #~ print "HERE1\n"; if ($gps_ready == 1){ eval{$ftp->put("$new_dir1\\$nick","$nick.bak") + or $error = 1;}; #~ HERES the Problem eval{$ftp->move("$nick.bak","$nick") or print +$ftp->message,"\n";}; #~ $ftp->move("$nick.bak","$nick") or die $ftp +->message; $gps_ready = 0; } eval{@list = $ftp->ls($ftp->pwd()) or $error = 1;} +; foreach my $kid (@list){ my $nkid; $nkid = substr($kid,28,5); if (defined($nkid )){ next if $kid eq "."; next if $kid eq ".."; next if $kid =~ /\.bak$/; next if $kid eq $nick; eval{$ftp->get($nkid,"$new_dir1\\$nkid.bak +") or $error = 1;}; } } # signal to create pf $gps_to_pf = 1; sleep 1; $sftp_start = 0 if $error == 1; if($sftp_start == 0){ last}; if($die == 1){ goto END }; } $ftp->quit; } else{ $sftp_start = 0; } } elsif ($sftp_start == 0 and $gps_start == 1){ sleep 1; $gps_to_pf = 1; $count++; print "Reconnecting...\n"; if ($count == 10){ $sftp_start = 1; $count = 0; $special = 1; } } else { sleep 1 } } END: }

Replies are listed 'Best First'.
Re: Error during Net::FTP::FILE::move
by marcussen (Pilgrim) on May 29, 2009 at 02:33 UTC

    You should change your password after publicly giving it out. The internet does not forget.

    Also, use warnings as well as strict, it really helps prevent those pesky uninitialized variables and other bad habits.

    Confucius says kill mosquito unless cannon
Re: Error during Net::FTP::FILE::move
by deadpickle (Pilgrim) on May 28, 2009 at 22:00 UTC
    OK maybe I was being to exact on the script. Here is a simple script that just puts a file in a directory and moves it, which copies and deletes the file. You will have to use your own ftp server to test it but its easier to debug. This script does not work either for me and I get the error: Failure writing to local file. which makes me think that it might be something with the ftp, maybe.
    #!/usr/bin/perl -w use strict; use Net::FTP; use Net::FTP::File; my $ftp = Net::FTP->new("updraft.unl.edu", Passive => 0); $ftp->login("uas",'grruvi'); $ftp->cdup; $ftp->cwd("/home/uas/Scripts/GPS/users"); $ftp->put("test.txt","test.bak") or die $ftp->message; $ftp->move("test.bak","test") or die $ftp->message; $ftp->quit;
      deadpickle:

      The error message indicates to me a problem creating the file on the local machine (rather than the FTP server). You may want to check permissions and disk space.

      ...roboticus