#!/bin/bash # Shell script to remove whole (nuke) ftp directory structure # See url for more info: # http://www.cyberciti.biz/tips/how-to-nuke-a-ftp-server.html # ----------------------------------------------- # Copyright (c) 2006 nixCraft project <http://cyberciti.biz/fb/> # This script is licensed under GNU GPL version 2.0 or above # ------------------------------------------------------------------------- # This script is part of nixCraft shell script collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information. # ------------------------------------------------------------------------- # NOTE: Requires ncftp/ncftlls ftp clients/commands # ========================================================================= # Ftp server settings ### change me ############################### # ftp login user FUSER='vivek' # ftp password FPASSWD='password' # ftp server ip/name FTPS='array05.wan.nixcraft.co.in' # ftp dirs to nuke Separate multiple dirs using # a blank/white space i.e. /dir1 /dir2) FTPDIRS='/dir1 /dir2' ############################################## for d in $FTPDIRS do subdires="$(ncftpls -u $FUSER -p $FPASSWD ftp://${FTPS}/${d}/)" for dir in $subdires do rdir="${d}/${dir}" ncftp -u"$FUSER" -p"$FPASSWD" $FTPS<<EOF cd $rdir rm * rmdir $rdir quit EOF done done # end of script
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- 10 Greatest Open Source Software Of 2009
- My 10 UNIX Command Line Mistakes
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our email newsletter to make sure you don't miss a single tip/tricks.
- Download Script
- Email this to a friend
- Rss Feed
- Last Updated: 04/9/08
{ 1 comment… read it below or add one }
nice script