I need to create a folder in my FTP server, whose name is "YYYY-MM-DD"; I have this variable:
slideshow=$(date +"%Y-%m-%d")
but I can not use it in FTP with mkdir, since it's a shell variable.
I've also tried with echo, and there it works (I have "mkdir 2015-05-25" in a sh file), but if I have a series of commands that have to be run, just the first ftp -n ftp.xxxx.it. is run, the rest (user, password) isn't.
I hope you could help me,
Thanks
this script seems to be like this topic enter link description here
but you can do it easily by mkdir a new directory on your pc then upload it to your server by this simple script
#!/bin/bash
Your Server credentials
ftp_server='******'
ftp_username='******'
ftp_password='******'
New folder with date in year with month and day
slideshow="`date +'%Y-%m-%d'`"
new_folder=`mkdir $slideshow`
Access Your Server via ftp then authenticate to your server
ftp -n $ftp_server <<END_SCRIPT
quote USER $ftp_username
quote PASS $ftp_password
Upload your new created folder
put $new_folder
then quit
quit
END_SCRIPT
full script
#!/bin/bash
ftp_server='********'
ftp_username='********'
ftp_password='********'
slideshow="`date +'%Y-%m-%d'`"
new_folder=`mkdir $slideshow`
ftp -n $ftp_server <<END_SCRIPT
quote USER $ftp_username
quote PASS $ftp_password
put $new_folder
quit
END_SCRIPT
来源:https://stackoverflow.com/questions/30436493/how-to-use-data-variable-in-mkdir-in-a-linux-server-with-ftp