Solved

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

Posted on 2013-12-16
6
350 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Fine Tune your automatic Updates for Ubuntu / Debian
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.

726 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