Store multiple FTP credentials in environment vars
In my current project we have to do 400 put operations (FTP) each day. Currently we have a script that reads server, user and password information from a text file. Then we have another txt file that contains the files we want to move and the server we want to put them (could be a different server for each file).
What I want to do is replace that script with a BuildForge project. I can't find a way of loading all the FTP login credentials into an environment and then use the appropiate one in the "put" step. Let's say I have ServerA and ServerB login credentials, how can I use ServerA info if the current file is going there? Thanks! |
3 answers
In my current project we have to do 400 put operations (FTP) each day. Currently we have a script that reads server, user and password information from a text file. Then we have another txt file that contains the files we want to move and the server we want to put them (could be a different server for each file). the best solution for this is a .netrc file on the ftp client system. http://www.manpages.info/sunos/netrc.4.html you could store all the credentials in the file, or have the step create one on the fly from the env group where you store them. |
I'll probably create the file on the fly, any idea how to iterate over all environment variables? What would be the best way of storing 30 login credentials (server-user-password) on an environment? Thank you! |
I'll probably create the file on the fly, any idea how to iterate over all environment variables? What would be the best way of storing 30 login credentials (server-user-password) on an environment? Thank you! as for the best way to store the credentials, I'd store the whole .netrc line in the env var. That simplifies storage as well as extraction. I'd create them with similar names, something like using a common prefix of FTPAUTH_ and using a shell script to access then in the environment. Something like: set | grep FTPAUTH_|cut -f2 -d= > $HOME/.netrc |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.