title: How to assign variables in a csh script and used them as arguments for that same script?
body: <p>Good day,</p>
  
  <p>Hoping for the kind help of anyone here, thanks in advance.
  I have T.csh which looks like this:</p>
  
  <pre><code>#! /bin/csh
  
  set a="01 02 03 04 05 06 07 08 09 10 11 12 13"
  set b="14 15 16 17 18 19 20 21 22 23 24 25"
  set c="01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25"
  
  set X = `grep $1 EOL.txt | head -n1 | cut -d- -f1`
  printf "$X\n$2\n$3\nYYYY\n1\nN\n"
  </code></pre>
  
  <p>The variables a,b and c are optionally used as the 3rd argument in the printf line. The problem is, whenever I try to run the script, it showed undefined variable. These set command lines are working whenever I assigned them interactively, but inside the script, it seems to not work. Perhaps I need to initialize it but could not figure out how. Just new to this programming thing, I hope someone here can help me. Thanks a lot in advance.</p>
  
  <p>Here are the sample execution and error for your reference:</p>
  
  <pre><code>CAT-46{bc2}40&gt;set a="01 02 03 04 05 06 07 08 09 10 11 12 13"
  CAT-46{bc2}41&gt;./T.csh 4773 XXXX.XX "$a"
  62
  XXXX.XX
  01 02 03 04 05 06 07 08 09 10 11 12 13
  82869
  1
  N
  CAT-46{bc2}42&gt;unset a
  CAT-46{bc2}43&gt;./T.csh 4773 XXXX.XX "$a"
  a: Undefined variable
  CAT-46{bc2}44&gt;
  </code></pre>
  
  <p>If i set the variables manually,it's OK, but when I called for it from the script, its flagging undefined variable error.</p>
  
  <p>Mike</p>