You are not logged in.

#1 2015-01-19 10:07:13

shajay12
Member
Registered: 2015-01-19
Posts: 1

shell script how getopts can accept more than one string in one var

In shell script   how  getopts  can  accept  more than one string in one variable    DES

Here is the part of shell script that accepts variables  from the Shell script  but the   DES   variable does not accepts more than one variable.,  how to do this ??

When i run the script like below

sh Ericsson_4G_nwid_configuration.sh   -n  orah4g    -d   "Ericsson 4g Child"    -z Europe/Stockholm

it does not accepts    "Ericsson 4g Child"    in  DES  Variable   and only accepts    "Ericsson"  to DES variable.
how to make it accept     full   "Ericsson 4g Child" 

========================================
while getopts “hn:r:p:v:d:z:” OPTION
do
  case $OPTION in
  h)
  usage
  exit 1
  ;;
  n)
  TEST=$OPTARG
  ;;
  z)
  ZONE="$OPTARG"
  ;;
  d)
  DES="$OPTARG"
  ;;
  v)
  VERBOSE=1
  ;;
  ?)
  usage
  exit
  ;;
  esac
done

Offline

#2 2015-01-19 16:10:35

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: shell script how getopts can accept more than one string in one var

Please use code tags when pasting to the boards: https://wiki.archlinux.org/index.php/Fo … s_and_Code


Also, see http://mywiki.wooledge.org/Quotes


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2015-01-19 16:25:04

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,331
Website

Re: shell script how getopts can accept more than one string in one var

Please post the full script (in code tags).  I suspect the problem is elswhere.  Is getopts actually running as top-level code, or is it in a function that you pass $@ to?  If the latter, make sure you quote "$@" when you pass it to the function.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB