Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Net::FTP direcory size question

by Todd Chester (Scribe)
on Feb 02, 2017 at 06:41 UTC ( [id://1180816]=perlquestion: print w/replies, xml ) Need Help??

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

With Net::FTP, is there a way to ask the size of a directory (like "du -s")?

Replies are listed 'Best First'.
Re: Net::FTP direcory size question
by GotToBTru (Prior) on Feb 02, 2017 at 07:00 UTC

    What does the documentation say? Given nothing specifically says it returns directory sizes, if you're brave you might try the quot command.

    I believe this is something you get to do yourself. Either the list(DIR) or the dir command will get you the data you require. I've used the latter but not the former.

    But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

      "quot (CMD ,ARGS)" is not clear if is a drop to a shell or an ftp command. It would be cool if I could do a "rm -rf xxx". I can with ftp on linux "! rm -rf /home/xxxx/ftp/MyDocsBackup/backup1"
        ! rm -rf /home/xxxx/ftp/MyDocsBackup/backup1
        AIUI, this removes locally, while the ->rmdir works on the remote…
      I have been using the ls command, which is the same as the dir command. I do not remember it giving me any additional data
        The doc's for Net::FTP say that ftp ls and ftp dir are not the same. This is not the normal command line.

        From Net::FTP:

        • ls ( DIR )
          Get a directory listing of DIR , or the current directory.
          In an array context, returns a list of lines returned from the server. In a scalar context, returns a reference to a list.
        • dir ( DIR )
          Get a directory listing of DIR , or the current directory in long format.
          In an array context, returns a list of lines returned from the server. In a scalar context, returns a reference to a list.
        Also note that du stats are not the same as ls stats. "du" is the size actually used on the disk. That will be at least equal to but, probably greater than the actual size of the file. That is because the file system writes to the disk in a quantum size of bytes, often 4096 bytes. Could be that the last byte of the file takes up one byte of this 4096 bytes. Other minimum "block" sizes to write to the disk are possible and there are a variety of names for what the file system calls this "minimum file system block size" on the disk.
Re: Net::FTP direcory size question
by soonix (Canon) on Feb 02, 2017 at 15:32 UTC

    Much of the information passed back by FTP is dependent on the server implementation (and config). There is no standard what should be a directory listing (and in which oder and which units).

    If a server doesn't send file sizes back, you won't get them, and there's nothing Net::FTP (or any other module) could do about it. Period.

    Of course, first you should check (with an interactive client), what you do get back from the server. That might be interesting for your other problem, too.

      I've used Firefox's Fire FTP plug-in and secure log-in variants to big success so far. If Firefox can get what I need, then I'm confident that Perl can do the same.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-03-28 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found