Troubleshooting
Problem
Using command-line tools with WebSphere® Application Server or WebSphere Liberty, you need to take into account special characters in use when using command-line arguments, including passwords and file directories. Special characters like dollar-signs, spaces, or percent signs have significance depending on what shell is being used.
Special characters aren't limited to passwords, but passwords can easily contain special characters. A file directory path passed as a command-line argument is another example, where quotation marks allows for paths with space characters to be read correctly.
Diagnosing The Problem
Special characters depend on the operating system (or even the shell in use).
Some common symbols one might encounter include the following:
Symbol | Operating System | Explanation |
---|---|---|
$
Dollar Sign
|
AIX®
Linux®
UNIX®
|
Used to represent an environment variable, such as $PATH
Characters after the dollar sign represent the name of the variable
When used in UNIX shell scripting, this character has even more meaning... specifically $$ represents the current process ID.
|
>
Greater Than
|
All Operating Systems
|
This operator is used to redirect the output from a command to a file.
|
<
Less Than
|
All Operating Systems
|
This operator is used to direct a file to be used as input for a command.
|
\
Back-Slash
(Yen symbol in some Windows character sets)
|
AIX
Linux
UNIX
Windows®
|
Windows: Used as a directory separator
Others: Used as the special character to escape other characters
|
/
Forward-Slash
|
N/A
|
Windows: Used in some command-line arguments for system commands
Others: Used as a directory separator in Linux and other UNIX environments.
IBM SDK can use both slashes interchangeably without consequence
|
%
Percent Sign
|
Windows |
Used to represent an environment variable when surrounded by a string (%PATH%)
Used to represent a command-line argument in a batch script, or variables in a FOR loop (%1)
Behavior differs slightly in batch scripting
|
^
Carat
|
Windows | Special character used to escape other characters on Windows |
Space Character
|
All |
The space character is used as a delimiter between arguments.
|
" OR '
Quotation marks
|
All |
Surround a string of characters (of an environment variable or command-line argument) to be treated as a single entry.
Especially used when the value contains a space character or other special characters
Make sure that the quotation marks aren't actually smart quotes, as those are not recognized by the command prompt in the same way a normal quotation mark is.
|
!
Exclamation Point
|
Windows | The exclamation character is a special character used in Windows when Delayed Expansion is enabled |
` grave-accent |
Windows (PowerShell™️) |
When commands are run within PowerShell, the escape character is the grave-accent (also known as the backtick).
This character has additional rules, including when used within double quotation marks, which are not covered in this document.
|
Resolving The Problem
Command-line arguments (including ones used in batch or shell scripts) might need to have special characters escaped.
Greater Than / Less Than
These operators are used to redirect output (or input) for a command.
If this is used within an argument and your intent is to include this character, the operating system may interpret this as one of the redirect operators instead. If you need to pass this in, surround the string containing this character with quotation marks, or follow directions for your operating system to escape a single character).
Quotation marks
- You can surround the entire string in single or double quotation marks
- "$abc" Renders as $abc
- "C:\Program Files" Allows for the space character to be escaped.
- If you need to escape a quotation mark itself, that might need to be done by using the escape sequences defined for the individual operating system
Smart Quotes and Dashes
Some applications transform "quotation marks" into “smart quotes”, or hyphens -- into dashes –, which may be interpreted incorrectly when using those characters in a command or custom property. This is common in word processors and email programs to transform these characters. Presentation software may also generate smart quotes and dashes too, which may even persist in more permanent forms like a PDF document or a slide deck.
" " Regular Quotation Marks
“ ” Smart Quotation Marks
- Regular Hyphen
– Smart Dash
The smart dashes are slightly longer than a hyphen, and the smart quotation marks are curved or slanted (depending on the font) instead of straight.
Double check that your pasted commands are using true quotes and dashes, otherwise you'll find that the command may fail or throw errors, which are really due to the transformed characters that couldn't be interpreted by the command.
Failing Command (with smart quotes and dashes)
keytool –list –keystore “/path/to/cacerts” –v
Illegal option: –list
Corrected Command
keytool -list -keystore "/path/to/cacerts" -v
Individual Escape Characters
Windows®
Use the carat character (^) to escape individual characters (use ^^ to escape the carat itself).
For exclamation marks, you might need to escape it with two carat characters under certain circumstances if delayed expansion is enabled (otherwise a single carat can be used)
For percent signs, which are used as the identifier for environment variables when surrounded by a string (%myvariable%), there are some specific rules to follow.
-
On the command prompt, you can escape the percent sign by using the carat symbol.
-
In a batch script, the percent signs need to be escaped by using double percent signs (%%)
-
To use the percent character in a quoted string, it must be escaped (unlike other special characters).
Example Input (Command-Line) | Resulting Output |
abc^123 | abc123 |
abc^^123 | abc^123 |
abc^ 123 | abc 123 |
^%abc^%
|
%abc% |
"^$$abc^^" | "^$$abc^^" |
hello ^"world^" | hello "world" |
C:\Program^ Files | C:\Program Files |
"abc%%abc%%" |
If the variable abc is not set,
the variable name and percent signs displays as:
abc%%abc%%
If set abc=123 is used instead,
the value displays as:
abc%123%
|
UNIX®, AIX®, Linux®
Use the backslash character (\) to escape an individual character (\\ escapes the backslash)
The environment variable identifier is the dollar-sign ($)
Example Input (Command-Line) | Resulting Output |
abc\$123 | abc$123 |
abc$123 |
Outputs differently, as $1 is a variable, but it might not be defined on the command line unlike a shell script:
abc23
|
abc$bcd |
If bcd hasn't been defined as an environment variable:
abc
|
/tmp/this\ has\ spaces/path/file\ 1.txt | /temp/this has spaces/path/file 1.txt |
file:\\\\Program\ Files | file:\\Program Files |
Document Location
Worldwide
[{"Line of Business":{"code":"LOB67","label":"IT Automation \u0026 App Modernization"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"ARM Category":[{"code":"a8m50000000CdJaAAK","label":"Security-\u003EAdministrative Security"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"},{"Line of Business":{"code":"LOB67","label":"IT Automation \u0026 App Modernization"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSD28V","label":"WebSphere Application Server Liberty Core"},"ARM Category":[{"code":"a8m50000000CdOoAAK","label":"Security-\u003ELiberty Profile"}],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"}]
Was this topic helpful?
Document Information
Modified date:
20 June 2024
UID
ibm16327229