title: How to set environment variables in tcl?
body: <p>When I source my <code>.cshrc</code> file and run the Tcl script it is working fine:</p>
  
  <pre class="lang-csh prettyprint-override"><code>$ source .cshrc-sample
  $ tclsh invoke.tcl
  </code></pre>
  
  <p>Following is the <code>.cshrc</code> file:</p>
  
  <pre class="lang-csh prettyprint-override"><code>setenv AUTOTEST "/auto/isbutest/frt"
  setenv ATS_EASY "$AUTOTEST"
  setenv ATS_USER_PATH "$AUTOTEST"
  setenv PATH "${AUTOTEST}/bin:${PATH}"
  </code></pre>
  
  <p>But when I tried setting the environment variable in Tcl itself and run the script,
  I get the following error:</p>
  
  <pre class="lang-tcl prettyprint-override"><code>$ tclsh invoke.tcl
  can't find package ha
      while executing
  "package require ha"
      (file "invoke.tcl" line 8)    
  </code></pre>
  
  <p>My Tcl script - <code>invoke.tcl</code>:</p>
  
  <pre class="lang-tcl prettyprint-override"><code>global env
  
  set env(AUTOTEST) "/auto/isbutest/frt"
  set env(ATS_EASY) "/auto/isbutest/frt"
  set env(ATS_USER_PATH) "/auto/isbutest/frt"
  set env(PATH) "$env(PATH):/auto/isbutest/frt/bin:";
  package require ha
  </code></pre>
  
  <p>How can I run the script without sourcing the <code>.cshrc</code>?</p>
  
  <p>The thing is setting environment variable is not possible using scripts, the lifetime of the variable is within the runtime of the script. When I tried printing the <code>PATH</code> variable it shows what is needed, but I don't know why it is not working. Is there any other workaround for this?</p>