Looking for an easy and strict way to process files and directories via FTP (in a shell script) I stumbled over the CurlFtpFS, which allows you to mount an FTP connection as part of your file system. It is an extremely nice and elaborated solution what these guys implemented. You can either mount it using sudo e.g. in /mnt/ftp/hostname or simply in your home directory, e.g. "~/ftp". As Bob Ross used to say: "And it's really that simple". If you only need to upload files in a shell script you might also be interested in the ftp-upload tool.
sudo aptitude install curlftpfs
# Create a directory to have a mount point mkdir ~/ftp # To directly connect with username and password in the command line: sudo curlftpfs username:firstname.lastname@example.org ~/ftp # If you want to type the password in the shell: sudo curlftpfs -o user="username" host.or.domain ~/ftp # To check if's mounted mount # You get a list that should include the line like: # curlftpfs#.... on ..../ftp type fuse (rw,nosuid,nodev,user=....)
sudo umount ~/ftp
Annotation: I added sudo because you very likely cannot unmount the drive without root permissions, even not in your home folder.