How to read a shell environment variable in your Tcl script. So anyone please help me. I am very new in TCL.
Environment variables are available to Tcl scripts in a global associative array env . The index into env is the name of the environment variable. The command puts "$env(PATH)" would print the contents of the PATH environment variable.
In side tcl script, you can simply do setenv as, setenv AUTOTEST="/auto/isbutest/frt" . if you want to set a variable, use set VARNAME "/auto/isbutest/frt" . if you want to get any environment variable, use $::env(AUTOTEST) .
Use $::env
to access any environment variables e.g. to access the TMP environment variable do this:
set tmpdir $::env(TMP)
More info here http://wiki.tcl.tk/1624
$ export var=42 $ tclsh % puts $env(var) 42
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With