Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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?



Replies are listed 'Best First'.
Re: Net::FTP wildcard delete?
by cowboy (Friar) on Jun 09, 2006 at 21:31 UTC

    Looking at the ftp docs at: 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://554555]
Approved by gellyfish
Front-paged by tye
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2017-04-29 13:34 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (532 votes). Check out past polls.