title: Tcl + Check file existence
body: <p>I'm trying to check if a file exists or not in Tcl, but I can't seem to get a true result. Even though I know it is present.</p>
  
  <pre><code>while {true} {
  
      if { [file exists $file_name] == 1} {               
          exp_send "copy file.txt destination \r"
          puts " File copied!"
      }
  
      puts "File Not copied"
  
      }
  </code></pre>
  
  <p>I always execute the File not copied line. I did a put for <code>[file exists $file_name]</code> and I always end up with 0. But I know for a fact that the file exists in the current directory. Any suggestions?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>An alternative method that I'm trying to pursue, is that when I do a <code>dir</code> using the tcl script. I will get an output of all the files in the directory. I just need to match my file with the list outputted and satisfy the <code>if</code> when a match was found ...</p>
  
  <p>I'm executing the script from Location A, but using the script to telnet to Location B. When I do a file exists, it checks Location A itself. This is my problem ... since I need to be searching in Location B ...</p>