users@glassfish.java.net

Re: GF 3.1.1 - asadmin create-sytem-properties - how to escape 'backslash'

From: Paul Davies <paul.m.davies_at_oracle.com>
Date: Wed, 21 Dec 2011 14:32:16 -0800

Hi,

After I followed up with the admin team, issue GLASSFISH-18069
<http://java.net/jira/browse/GLASSFISH-18069> was filed against the docs
to provide the missing clarifications.

Regards,
-Paul


On 12/20/2011 7:46 AM, Paul Davies wrote:
> Hi Bernhard,
>
> You're welcome and thanks for this clarification.
>
> On Linux systems, the backslash character is itself a special
> character and so, therefore, must be escaped. As a result, 4
> backslashes are need to specify the \ in an option argument on Linux
> systems:
>
> $ asadmin create-system-properties --target pmdconfig
> mydir=C\\:\\\\glassfish\\\\glassfish3
> Command create-system-properties executed successfully.
> $ asadmin list-system-properties pmdconfig
> The target pmdconfig contains following 11 system properties
> ...
> mydir=C:\glassfish\glassfish3
> Command list-system-properties executed successfully.
>
> However, even on a Linux system, it seems that a single \ as an escape
> character is sufficient for the set subcommand:
>
> $ asadmin set
> configs.config.pmdconfig.java-config.native-library-path-prefix=C\:\\glassfish3\\glassfish
> configs.config.pmdconfig.java-config.native-library-path-prefix=C:\glassfish3\glassfish
> Command set executed successfully.
> $ asadmin get
> configs.config.pmdconfig.java-config.native-library-path-prefix
> configs.config.pmdconfig.java-config.native-library-path-prefix=C:\glassfish3\glassfish
> Command get executed successfully.
>
> This inconsistency is not documented. I'll follow up to see if it
> should be.
>
> Regards,
> -Paul
>
>
> On 12/20/2011 7:28 AM, Bernhard Thalmayr wrote:
>> Thanks for your investigestions Paul , much appreciated.
>>
>> I should have mentioned that I run 'asadmin' from a Linux box ... not
>> from a Windows box (secure admin, remote asadmin call)
>>
>> If I do not escape the 'colon' the shell can not deal with the
>> command at all.
>>
>> The 'set' command works in this constellation, however the
>> create-system-properties does not ... the backslash is never escaped
>> leading to a missing backslash in the value when viewing the config
>> through the web-console.
>>
>> -Bernhard
>>
>> On Tue, Dec 20, 2011 at 4:18 PM, Paul Davies
>> <paul.m.davies_at_oracle.com <mailto:paul.m.davies_at_oracle.com>> wrote:
>>
>> Hi,
>>
>> At least some of the inconsistencies that you observe are the
>> expected (and documented) behavior for these subcommands.
>>
>> According to the asadmin(1M)
>> <http://docs.oracle.com/cd/E18930_01/html/821-2433/asadmin-1m.html#scrolltoc>
>> man page, the colon must be escaped if it is part of a property
>> or a Java Virtual Machine option. As the colon in the set command
>> is not part of a property, I do not believe that the colon in the
>> drive ID should be escaped.
>>
>> The asadmin(1M) man page also states that on Windows systems in
>> single command mode, the backslash character does not require an
>> escape character.
>>
>> My experiments with the set command are consistent with these
>> observations. No escape characters seem to be required in a
>> Windows path if the command is run in single mode on Windows:
>>
>> C:\>asadmin set
>> configs.config.pmdconfig.java-config.native-library-path-prefix=C:\glassfish3\glassfish
>> configs.config.pmdconfig.java-config.native-library-path-prefix=C:\glassfish3\glassfish
>> Command set executed successfully.
>>
>> C:\>asadmin get
>> configs.config.pmdconfig.java-config.native-library-path-prefix
>>
>> configs.config.pmdconfig.java-config.native-library-path-prefix=C:\glassfish3\glassfish
>> Command get executed successfully.
>>
>> If I try to escape the colon and backslash characters, the escape
>> characters are part of the attribute value that is set:
>>
>> C:\>asadmin set
>> configs.config.pmdconfig.java-config.native-library-path-prefix=C\:\\glassfish3\\glassfish
>> configs.config.pmdconfig.java-config.native-library-path-prefix=C\:\\glassfish3\\glassfish
>> Command set executed successfully.
>>
>> C:\>asadmin get
>> configs.config.pmdconfig.java-config.native-library-path-prefix
>> configs.config.pmdconfig.java-config.native-library-path-prefix=C\:\\glassfish3\\glassfish
>> Command get executed successfully.
>>
>> However, with create-system-property, it seems that the colon and
>> backslash characters must be escaped, even on Windows systems in
>> single mode:
>>
>> C:\>asadmin create-system-properties --target pmdconfig
>> mydir=C\:\glassfish\glassfish3
>> Command create-system-properties executed successfully.
>>
>> C:\>asadmin create-system-properties --target pmdconfig
>> yourdir=C\:\\glassfish\\glassfish3
>> Command create-system-properties executed successfully.
>>
>> C:\>asadmin list-system-properties pmdconfig
>> The target pmdconfig contains following 2 system properties
>> mydir=C:glassfishglassfish3
>> yourdir=C:\glassfish\glassfish3
>> Command list-system-properties executed successfully.
>>
>> This behavior contradicts the statement in the asadmin(1M) man
>> page that on Windows systems in single command mode, the
>> backslash character does not require an escape character. I'll
>> follow up with the admin team to see if an issue is required
>> against asadmin, create-system-properties or their man pages.
>>
>> Instead of escaping the colon and backslash characters
>> individually, you can enclose the entire path in single quote (')
>> characters:
>>
>> C:\>asadmin create-system-properties --target pmdconfig
>> ourdir='C:\glassfish3\glassfish'
>> Command create-system-properties executed successfully.
>>
>> C:\>asadmin list-system-properties pmdconfig
>> The target pmdconfig contains following 3 system properties
>> mydir=C:glassfishglassfish3
>> yourdir=C:\glassfish\glassfish3
>> ourdir=C:\glassfish3\glassfish
>> Command list-system-properties executed successfully.
>>
>> Hope this helps.
>>
>> Regards,
>> -Paul Davies
>>
>>
>> On 12/20/2011 5:34 AM, Bernhard Thalmayr wrote:
>>> Hi experts,
>>>
>>> somehow it seems that the handling of backslashes is different
>>> for the different asadmin commands.
>>>
>>> Escaping a backslash using the 'create-system-properties does
>>> not seem to work, but escaping a backslash using the 'set'
>>> command works as expected (paths look correct using the console)
>>>
>>>
>>> set
>>> <config-name>.java-config.native-library-path-prefix=C\:\\<some-dir>\\<some-subdir>
>>>
>>> vs.
>>>
>>> create-system-properties --target <some-config>
>>> <SOME-VAR>=C\:\\<some-dir>\\<some-subdir>
>>>
>>> Any pointers avaialble?
>>>
>>> TIA,
>>> Bernhard
>>>
>>> --
>>> IT-Consulting Bernhard Thalmayr
>>> - Painstaking Minds -
>>> 83620 Vagen (Munich area)
>>> Germany
>>
>>
>>
>>
>> --
>> IT-Consulting Bernhard Thalmayr
>> - Painstaking Minds -
>> 83620 Vagen (Munich area)
>> Germany