Solutions

How to pass a dollar character ($) in an argument to a PCLI command



ID:    S141561
Published:    05 February 2016
Updated:    22 February 2016

Operating System(s)

  • All Unix
  • All Windows

Product(s)

  • PVCS Version Manager
 

Description

The PCLI command interpreter uses the $ character to expand variables. For example, using $VAR or ${VAR} will cause this value to be replaced with the contents of the PCLI or environment variable named VAR.
 
As a result of this feature, special care needs to be taken if any of the arguments you want to pass to PCLI require a literal $ character.

Resolution

To avoid literal $ characters from being used to expand variables, they need to be escaped:
 
  • Windows:

    Replace every $ with $$$

  • Linux/UNIX:

    Replace every $ with \\\$\\\$\\\$

    This is more complicated than Windows because PCLI and the UNIX shell both interpret $ characters.

An alternate solution is available for four common PCLI arguments that have environment variable counterparts:
 
  • Project Database

    If the option -pr is not passed, PCLI will attempt to use the variable PCLI_PR
     
  • User Credentials (UserID:Password)

    If the option -id is not passed, PCLI will attempt to use the variable PCLI_ID
     
  • Project Path

    If the option -pp is not passed, PCLI will attempt to use the variable PCLI_PP
     
  • Workspace

    If the option -sp is not passed, PCLI will attempt to use the variable PCLI_SP
     
The contents of variables are not subject to variable expansion rules, so instead of escaping the $ characters in the PCLI arguments shown above, you can leave those arguments off and specify the value 'as is' in the contents of the corresponding variable.
 
The following examples are equivalent to access the project database "\\server\C$\mypdb" as user "Admin" with password "Top$ecret":
 
  • Windows:

    • pcli get -pr"\\server\C$$$\mypdb" -id"Admin:Top$$$ecret" -z /
       
    • set PCLI_PR=\\server\C$\mypdb
      set PCLI_ID=Admin:Top$ecret
      pcli get -z /

       
  • Linux/UNIX:
     
    • pcli get -pr"\\\\server\\C\\\$\\\$\\\$\\mypdb" -id"Admin:Top\\\$\\\$\\\$ecret" -z /
       
      The \ character is an escape character in UNIX shells, requiring that character to be escaped itself.
       
    • pcli get -pr"//server/C\\\$\\\$\\\$/mypdb" -id"Admin:Top\\\$\\\$\\\$ecret" -z /
       
      Version Manager accepts \ and / as path separators, so by using / you can avoid having to escape the \ path separator.
       
    • export PCLI_PR='\\\\server\\C$\\mypdb'
      export PCLI_ID='Admin:Top$ecret'
      pcli get -z /
       
      Using single quotes when assigning an environment variable avoids the UNIX shell from interpreting the $ character.
       
    • export PCLI_PR='//server/C$/mypdb'
      export PCLI_ID='Admin:Top$ecret'
      pcli get -z /

Rate this Solution

Find Answers

Type a question or describe what you are looking for below

My Recent Searches

Welcome kb sso

Additional Assistance

  • Submit a Case Online
  • FAQs