I ran into something that seemed unusual (and frustrating) last night, and wanted to see if anyone could help me understand it, and maybe even show me a better way to work around it. I was writing a script that would (among other things) use the ftp client to create a directory on one of our FTP servers. I set up an FTP script in a loop with a heredoc and passed FTP the username, password and directory names with variables, so the FTP portion of the script looked like this:
Code: Select all
ftp -n ftphost << EOS
user $ftpuser $ftppass
mkdir /exisiting_dir/$newdir
bye
EOS
For anyone who has encountered the same problem, here's my solution:
Contents of the ~/.netrc file:
Code: Select all
machine ftphost
login mylogin
password mypassword
Code: Select all
...
echo mkdir /existing_dir/$newdir >> /tmp/cmds.ftp
echo bye >> /tmp/cmds.ftp
ftp ftphost < /tmp/cmds.ftp
rm /tmp/cmds.ftp
...
Why won't the CentOS 6.8 ftp client handle variables correctly?
What do I need to do to make the FTP client on CentOS 6.8 work with variables?
Thank you,
Jason