Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: comparing files after FTP

by nsyed (Novice)
on Oct 16, 2003 at 13:26 UTC ( [id://299737]=note: print w/replies, xml ) Need Help??


in reply to Re: comparing files after FTP
in thread comparing files after FTP

Hi Vek, Its returning the size 0. Any more suggestions? Thanks

Replies are listed 'Best First'.
Re: Re: Re: comparing files after FTP
by vek (Prior) on Oct 16, 2003 at 14:36 UTC

    Take a peek at File::Listing's parse_dir function. You should be able to grab the file size by using that. Untested:

    use File::Listing qw(parse_dir); # your ftp code here. my @dirlist = $ftp->ls("-l"); for (parse_dir(@dirlist)) { ($name, $type, $size, $mtime, $mode) = @$_; next if $type ne 'f'; # only want plain files print "Size of $name is $size\n"; }
    -- vek --
Re: Re: Re: comparing files after FTP
by nsyed (Novice) on Oct 17, 2003 at 15:36 UTC
    I tried to make it simple but still doesn't work. It returns nothing. Please let me know if you can find anything wrong with this code or modify to get the size of the remote file. Thanks
    #!/usr/bin/perl use strict; use Net::FTP; my $user = "someuser"; my $passwd ="password";; my $host = "someFTPserver.com"; my $file = "somefile.txt"; my $ftp = Net::FTP->new($host) or die "$@"; $ftp->login($user, $passwd) or die $ftp->message; my $dir = "/home/somedir/mydir/dest"; $ftp->cwd($dir) or die "Can't cwd to $dir\n"; my $remote_size = $ftp-> size($file); print ("The source file size is :", $remote_size , "\n"); $ftp->quit;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://299737]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-23 20:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found