I would like to remove a folder in my FTP server, hosted by PureFtpd, in a script, to automate this task. I've a bash script like that:
#!/bin/sh
HOST=myhost.com
USER=my-user
PASSWORD=my-password
ftp -inv $HOST <<EOF
user $USER $PASSWORD
cd /folder_A
ls
rmdir -r assets
bye
EOF
The server gives this feedback:
Connected to myhost.com.
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 160 allowed.
220-Local time is now #####. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 5 minutes of inactivity.
331 User my-user OK. Password required
230-Your bandwidth usage is restricted
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
250 OK. Current directory is /folder_A
200 PORT command successful
150 Connecting to port 49849
drwxr-xr-x 3 3012 my-user 3 Oct 8 07:29 .
drwxr-xr-x 11 3012 my-user 16 Oct 7 22:49 ..
drwxr-xr-x 3 3012 my-user 13 Oct 7 22:46 assets
226-Options: -a -l
226 3 matches total
550 Can't remove directory: No such file or directory
221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
221 Logout.
I understand that the "assets" folder does not exists, but the filezilla exploration show me that the folder still present.
I've tried to run without success the following command:
rmdir -r /folder_A/assets
Many searches on Google provided no solution. Next idea is to try ChatGPT...
Thanks to all. There is no possibility to delete a non-empty folder using the standard FTP. My solution is to rename the folder with my script (suffixing with "-old-$DATE") and create a new directory structure. Once a week / a month, I use Filezilla to remove all renamed folders, because this tool have the feature to delete a folder recursively.