I’m having a lot of trouble with a script i’m writing that will upload a file to a remote ftp server.
We have software that generates files in this format:
filename-`date +"%Y%m%d"`
My problem is that I can’t get ftp to expand that date expression, I’d like to be able to do a simple:
put filename1-`date +"%Y%m%d"`
from .netrc or from stdin like:
ftp -n ftp.server.com < ftpcommands.txt
I’ve tried these but ftp takes the date expression literally and I get a
“filename1-`date….file not found”
Does anyone know a way in which I could get this resolved?
Also, does anyone know if you can specify the ftp sub-commands on the command line?
I’m having trouble finding examples on it. If that’s possible then bash would expand the date expression and pass it to ftp but I haven’t found any options that fit the bill.
I’m using the bash shell
Thanks!
The ftp program doesn’t perform shell expansions. One thing you could do is:
The here-document will be expanded by Bash to do what you want.