Solved

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

Posted on 2013-12-16
6
342 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
Comment Utility
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 37

Assisted Solution

by:Gerwin Jansen
Gerwin Jansen earned 250 total points
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 29

Expert Comment

by:MikeOM_DBA
Comment Utility
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
Comment Utility
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
Comment Utility
thanks for your quick response
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now