Why doesn’t mget and mdelete play nice together? July 16, 2009
Posted by Rajeesh in linux.Tags: hacking, linux
trackback
One of my colleagues needed a shell script which should:
- connect to an external system via FTP
- change to a remote directory
- get all the files in the directory to local machine
- and delete all the files in the remote directory
The ftp commands mget and mdelete can be used to retrieve and delete multiple files respectively. And the code snippet would be:
do_ftp()
{
rm -f $FPTLOG
ftp -n -v <remote_host> <<FTP >$FTPLOG 2>&1
user <user> <password>
cd $REMOTE_DIR
lcd $LOCAL_DIR
mget *.txt
mdelete *.txt
bye
FTP
}
This should do the job, right? Unfortunately it doesn’t. mget works, but the mdelete afterwards isn’t triggering at all when I checked vsftpd.log.
I managed to save the day by putting a harmless command in between (looks like they need a mediator!).
mget ZCNT_RECON_FBL1N_*.txt
ls #Needed this for mdelete to work
mdelete ZCNT_RECON_FBL1N_*.txt
Geeks, any explanation on why this happens?

Comments»
No comments yet — be the first.