Pete Helgren wrote:
Here is the issue. I would like to define an environment variable that will be used to substitute another value in another variable.
You must've (incorrectly) specified something like this:
Change it to double-quotes like this:
Some characters have special meanings in Unix shells (including QShell). In your example, the dollar-sign means "insert variable here", there are other special characters, such as spaces that separate different parameters, etc. Quote marks are used to control how these special characters are interpreted by the shell.
There are three types of quote marks:
a) Double-Quotes (sometimes called "weak quotes"). In these, wildcards, single-quotes and spaces are treated literally, but other special characters are still treated specially.
b) Single-Quotes ("strong quotes"). Almost everything is treated literally... (The only exception that comes to mind is the backslash)
MESSAGE='Lemonade costs $1.00'
Lemonade costs $1.00
c) Back-Quotes (this looks like a single quote, but it's slanted the opposite direction). This means that whatever's in the string should be run, as a command, and the stdout of the program should be inserted into your variable.
SPLF=`catsplf -j 608553/KLEMSCOT/W6S1 QSYSPRT 17 | grep "Total:"`
the SPLF envvar will contain the line of the spooled file (from the job number, spooled file name, and spooled file number listed above) that contains the word "Total:".
Pretty neat :)
More about Unix quoting here:
Anyway... your issue is that you used single-quotes, which prevent the dollar-sign from being treated as a special character -- so your variable isn't expanded. Using double-quotes lets you expand the variable.