Sometimes there is a necessity to change directory permissions on remote FTP host. It is okay if this is needed for 1-2 folders, but what if there are hundreds of them? In my case it was even worse, it was tree of folders, with sub- and sub-sub-folders inside, kind of image cache!
At first I was little frustrated, because I did not know they way how to do it. Short after I read a man of my favorite and powerful ftp tool called lftp. It must be able to do it, because it can do much more like deploying project via ftp.
Here is simple example of recursive remote ftp directory chmod
#!/bin/bash lftp <<EOF set ftp:ssl-allow no set ftp:passive-mode true set ftp:list-options -a open -u [user],[password] [host] chmod -R 0777 /public_html/images/cache EOF
It will set 777 (read/write for all) permissions for cache folder and all sub-folders (files too).
Just one command makes life easier!