Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
The stupid question is the question not asked
 
PerlMonks  

Net::FTP wildcard delete?

by cormanaz (Chaplain)
on Jun 09, 2006 at 21:05 UTC ( #554555=perlquestion: print w/ replies, xml ) Need Help??
cormanaz has asked for the wisdom of the Perl Monks concerning the following question:

Howdy Monks. I am using mod Net::FTP and I want to issue a command to delete multiple files on the server. However, according to the docs it only offers a delete method, not an mdel or mdelete method like some FTP clients. Is there a way to do what I want without reading a file list from the server then deleting one at a time?

Thanks....

Steve

Comment on Net::FTP wildcard delete?
Re: Net::FTP wildcard delete?
by cowboy (Friar) on Jun 09, 2006 at 21:31 UTC

    Looking at the ftp docs at: http://www.w3.org/Protocols/rfc959/4_FileTransfer.html there is no mdel or mdelete command.

    I think clients such as ncftp that implement them actually read a list in the background if required (or actually pass the wildcard to the server to deal with - not sure here). I do know ncftp gets its tab completion by pulling up lists in the background, it just hides it unless you actually ask for it.

      Looks like the server does it. According to man ftp:
      For mdelete and mget, each remote file name is expanded separately on the remote machine and the lists are not merged.
      Of course, if you really want to know how it's done (and you have root access), a packet sniffer is your friend.

        No, "The file list is expanded on the remote machine" does not imply "MDEL is an FTP command". The list is expanded remotely by issuing an NLST command (as shown below). MDEL is not an FTP command.

        ftp> prompt Interactive mode off. ftp> debug <-- Don't need a packet sniffer Debugging on (debug=1). ftp> quote MDEL yoink* <-- remote MDEL ---> MDEL yoink* 500 MDEL yoink*: command not understood. ftp> mdel yoink* <-- local MDEL ---> EPSV ---> NLST yoink* <-- remote expantion ---> DELE yoink <-- individual deletes 250 DELE command successful. ---> DELE yoinks 250 DELE command successful.
Re: Net::FTP wildcard delete?
by Argel (Prior) on Jun 09, 2006 at 21:54 UTC
    Most implementations of protocols add a lot of niceities for users. Even ones we would consider archaic, like a plain old implementation of ftp. For example, the whole concept of a current working directory is actually handled by the client, at least with Net::SFTP (and I see no reason wy Net::FTP would be different). Internally, everything is full pathed. It can be an eye opener but it is also a great opportunity to understand how some of these common protocols we take for granted actually work.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://554555]
Approved by gellyfish
Front-paged by tye
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-04-18 06:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (462 votes), past polls