create-custom-resource with colon

8 views
Skip to first unread message

Hans Pikkemaat

unread,
May 10, 2021, 1:55:54 PM5/10/21
to Payara Forum
Hi,

I'm creating a custom resource with a URL in it.

I want to do it using a postboot script and I know how to do it but the way I need to do it is weird and I want to understand why this is necessary.

Let explain with two examples, one is when I just run asadmin with parameters and two is where let asadmin load the command from stdin using a pipe.

1.
There a colon in my url so I wrap the value in double quotes

asadmin create-custom-resource --restype java.lang.String --factoryclass org.glassfish.resources.custom.factory.PrimitivesAndStringFactory --property value=\"http://google.com\" test

I'm using bash so I escape the double quotes so they are actually sent to asadmin so he knows that the : can be taken literally.

All good and very logical and according to docs.

2.

To be clear, the goal is to not having to escape the colon in my value because I'm getting the value through a env var and I really don't want to fiddle with that value.

I tried everything (I think) but the only thing I found that works is this

echo "ccreate-custom-resource --restype java.lang.String --factoryclass org.glassfish.resources.custom.factory.PrimitivesAndStringFactory --property value="'http://google.com'" test
reate-custom-resource --restype java.lang.String --factoryclass org.glassfish.resources.custom.factory.PrimitivesAndStringFactory --property value=\"'http://google.com'\" test" |asadmin

To make it a bit more readable, this is the command that asadmin is receiving

create-custom-resource --restype java.lang.String --factoryclass org.glassfish.resources.custom.factory.PrimitivesAndStringFactory --property value="'http://google.com'" test

It is still not very readable but the value being sent is

<double quote><single quote>http://google.com<single quote><double quote>

The quotes can also be reverted, so first single quote and then double quote.

So I don't understand why both the double and single quotes are required.

best regards, Hans
Reply all
Reply to author
Forward
0 new messages