Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read Bash environment variable in TCL

Tags:

tcl

How to read a shell environment variable in your Tcl script. So anyone please help me. I am very new in TCL.

like image 864
galvin Verghese Avatar asked Apr 01 '11 08:04

galvin Verghese


People also ask

How do you call an environment variable 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.

How do I set environment variable in tcl Mcq?

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) .


2 Answers

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

like image 198
TrojanName Avatar answered Sep 22 '22 19:09

TrojanName


$ export var=42 $ tclsh % puts $env(var) 42 
like image 41
hynek Avatar answered Sep 20 '22 19:09

hynek