Ric Rocheleau wrote:
> Hello All
>
> I am trying to set some variables in a module file to execute
> some setup scripts.
>
> In /bin/sh, I can do variable_name=`env | grep SHELL`
> then feed that output into an if/then statement
>
> What is the syntax in TCL ?
Hello, Ric.
In Tcl, you use $env to pick up environment variables
as so:
set variable_name $env(SHELL)
Note that you don't use the $ if you're checking for
existince with "info exists". An example of usage
in this context would be
if [info exists env(SHELL)] {
set variable_name $env(SHELL)
}
The above can be tested using tclsh; it's all plain
Tcl code.
And as for a "sh" script, I've always used the $ notation
to access shell/env vars. To capture the value of the
SHELL variable, you can just do
variable_name=${SHELL}
(brackets optional) which avoids calling the external "env"
program.
Hope this helps,
- Leo Butler
|