I have multiple server names that I need to use in a switch statement, but I don’t want to hardcode the values of the server names incase they change, or I need to load the software on a new server. Any ideas would be greatly appreciated?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, it certainly sounds like you need to load them from a configuration file of some kind (or have them passed in on a command line) – but if you don’t know the names ahead of time, what would you actually want to switch on?
Consider what your real goal is – are you trying to take different actions for production servers versus test servers, for example? Work out how you want to group the servers, and then you’ll have more of an idea about what information you’ll need to express in the configuration file.