Solved

source command inside a shell script does not work if a key contains multiple values

Posted on 2013-12-16
6
346 Views
Last Modified: 2013-12-22
I have a file, interfaceDetail , who content are as below:

AP=Northbound
AC=Southbound
RADIUS=Northbound

Now when i change interfaceDetail's content to below:

AP=Northbound
AC=Southbound
RADIUS=Southbound Northbound

i get the error " line 3: Northbound: command not found"  from all places where i try to source interfaceDetail .
How do i have multiple values to my key in a source file?
0
Comment
Question by:pvinodp
6 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 250 total points
ID: 39723256
Depending on how RADIUS is used in the shell script,
and maybe on which shell is running the script, you might use
RADIUS='Southbound Northbound'
or perhaps
RADIUS=(Southbound Northbound)
0
 
LVL 38

Assisted Solution

by:Gerwin Jansen, EE MVE
Gerwin Jansen, EE MVE earned 250 total points
ID: 39723289
or double quotes:

RADIUS="Southbound Northbound"

If that doesn't work can you post (part) of a script where you source/use RADIUS?
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 39723625
Can you explain what you mean by "multiple values" how you are going to use them?

If you want just to assign the values to the variable then just put " or ' around the values
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 39725014
try:
AP=Northbound
AC=Southbound
RADIUS="$AP $AC"
#   Or ...
 set -A RADIUS $AP $AC

Open in new window

0
 
LVL 4

Expert Comment

by:Ramakanta Sahoo
ID: 39731332
In Bash you can do something like below

#!/bin/bash
RADIUS=( Southbound Northbound )

for radius in ${RADIUS[@]}
    do
    # DO whatever you want to do here
    echo $radius
    done
0
 

Author Closing Comment

by:pvinodp
ID: 39735426
thanks for your quick response
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question