I use the following SSH script to upload *.jpg files via FTP:
#!/usr/bin/expect
set timeout -1
spawn ftp -v -i [ftp server]
expect "[some word on the last line of server response]"
send "[login]\r"
expect "Password:"
send "[password]\r"
expect "ftp>"
send "mput *.jpg\r"
expect "ftp>"
send "quit\r"
[...] replaced with actual ftp server/account data.
Now I want to modify this script to do the same for FTP over explicit TLS/SSL
You will need a ftp-client that is able to connect via FTPS. The man-page of your ftp-client should tell you if its possible.
A client that can talk TLS/SSL is lftp.
I use the SSH script to transfer jpg files from a remote hosting server to ftp servers. I access the hosting server via SSH client and run the script to initiate the ftp file transfer. Works well. However, now I need to do the same with a FTP server over explicit TLS/SSL.
When I just replace
spawn ftp ...
for
spawn lftp ...
it derails the script. I don't know why and how to modify the script accordingly...
lftp is an external program you'll have to install on the hosting server if you wish to use it. There are other clients out there that speak ftps, but I found lftp to be the easiest to use.
It is scriptable, so no need to use expect. If you switch to lftp your script could look like this:
/path/to/lftp -u [login],[password] ftp://[ftp server] <<EOF
# the next 2 lines put you in ftpes mode
set ftp:ssl-force true
set ftp:ssl-protect-data true
mput *.jpg
exit
EOF