Help needed with array

Hello all.

I am in the process of moving a script over from Linux to FreeBSD and encountered issues with the below array:
Code:
DNS_SLAVE_ARRAY=(
"example1.lab.com" \
"example2.lab.com" \
)
It seems BSD requires double quotes enclosing the string after the equal sign, however the needed double quotes around the nameserver values are of course causing issues. I tried \" and \' etc... but no go (likely due to the required backslash at the end of each nameserver line):
Code:
DNS_SLAVE_ARRAY"=(
"ns1example.lab.com" \
"ns2example.lab.com" \
)"

Any thoughts on how I can get around this?
 
What kind of script? Shell script?

Because if this is a shell script then it's probably very easy to solve: install the appropriate shell. Most Linux environments rely heavily on shells/bash, so if you install that then its quite likely that this script will work once more.

Otherwise I'd advice you to look into sh(1) which will explain all there is to know about arrays.
 
Hi. yes it's a shell script set with the following:
Code:
#!/bin/sh
The script will be running on vendor appliances so likely will not be permitted to install shell. I just need to find a way to run it as is and thanks.
 
Whoever put #!/bin/sh at the top of your script should be spanked. Had you taken ShelLuser's advice, you'd know there are no arrays in POSIX-conformant shell code. If you can't install another shell, you're going to have to modify the script.
 
Back
Top