Ask Your Question

Regsubst not picking up the groups

asked 2017-12-21 10:54:42 -0500

itaremyinitials gravatar image

I have a variable with a value : [] I would like to get rid of the curly brackets, so I decided to use regsubst. And this is how I am using it given that var1=[]

  notify {"This is the value for ipaddress ${var2} ":}

Unfortunately, this is not returning the correct value that I want which is without the curly brackets. I need help figuring out what am I missing.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-12-21 13:43:08 -0500

stivesso gravatar image

updated 2017-12-21 13:45:37 -0500

Hi itaremyinitials,

It seems like the main reason for that wrong output comes from the way $var1 was defined, if it is defined without simple quote, then it is most probably interpreted as an array (not as a String), you must have a single quote to make sure that the curly brackets are not interpreted (see the output below).

With this code, I get the correct output

notify {"This was the value before: ${var1} ":}
notify {"This is the value after: ${var2} ":}


Notice: This was the value before: []
Notice: /Stage[main]/Main/Notify[This was the value before: [] ]/message: defined 'message' as 'This was the value before: [] '
Notice: This is the value after:
Notice: /Stage[main]/Main/Notify[This is the value after: ]/message: defined 'message' as 'This is the value after: '
Notice: Applied catalog in 0.16 seconds
edit flag offensive delete link more


Thanks a lot @stivesso that was it

itaremyinitials gravatar imageitaremyinitials ( 2017-12-27 01:48:50 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-12-21 10:54:42 -0500

Seen: 15 times

Last updated: Dec 21 '17