Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable assignment and special chars problem

Status
Not open for further replies.

LGTOserv

IS-IT--Management
Aug 20, 2001
25
US
Hi All;

I am having an issue figuring out how to input a value that has special chars and using that var as follows:

input value(no quotes):

name:phone



Script:
" location='${USERINFO}' "

USERINFO doesnt seem to be formatted correctly due to the ":" in the input value. any ideas?

thanks in advance.
 
The single quotes prevent the shell to expand the var value ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the quick response. Seems when i take the quotes off so it looks like this:

Script:
"location=${USERINFO}"

I get a parse error:

Resource parse error: unterminated value list
name:phone
^


any suggestions?
thanks
 
And this ?
location="${USERINFO}"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

It already has " " around it though, can i do this?

eg:

"location="${USERINFO}""

thanks.


 
Hi

You can put quotes, single or double, around values, but you can not put it around commands.

Or do you have a reason for insisting on the outer double quotes ( " ) ?

Feherke.
 


i see, i am trying to run a command and pass it some values from an input file. The command takes these input values from the file and uses them as parameters. for instance

input/parameter file:
value1,Jim:(123)123-1234 (this is in an input file of parameters

input is read into a var called USERINFO in script

Script:
this runs a command like: root# findperson "person='${USERINFO}'" <-- input value to command findperson.

i think this would work ok without the ":" but it seems to choke on the colon for some reason. if the input value was for instance Jim(123)123-1234 instead of Jim:(123)123-1234, it would probably work as i wouldn't get the parse error. I am unsure how to handle the extra ":" in the input value.

hope thats a little clearer.

thanks
 
It seems to me that you should be able to remove the single quotes completely. The double quotes around the entire "person=${USERINFO}" segment forces the entire bit to be ${1} to findperson (including embedded whitespace).

I tried:
Code:
sagan$ echo "person=value1,Jim:(123)123-1234"
person=value1,Jim:(123)123-1234
sagan$

also

Code:
sagan$ USERINFO="value1,Jim:(123)123-1234"
sagan$ echo ${USERINFO}
value1,Jim:(123)123-1234
sagan$ echo "person=${USERINFO}"
person=value1,Jim:(123)123-1234
sagan$

It looks to me as if the shell is handling the string fine, my next thought would be to run the findperson script manually and see if it behaves as expected.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top