Tcl +检查文件存在 [英] Tcl + Check file existance
问题描述
while {true} {
if {[文件存在$ file_name] == 1} {
exp_sendcopy file.txt destination \r
putsFile copied!
puts文件不被复制
}
我总是执行File not copied行。我做了一个放$ 编辑: 另一种方法,我想追求,是当我做一个 我从位置A执行脚本,但使用脚本telnet到位置B.当我做一个文件存在时,它检查位置A本身。这是我的问题...因为我需要在位置B搜索... 而且你想要一个 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. I always execute the File not copied line. I did a put for EDIT: An alternative method that I'm trying to pursue, is that when I do a 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 ... The And you want a 这篇关于Tcl +检查文件存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
dir
使用tcl脚本。我将得到目录中所有文件的输出。我只需要匹配我的文件与输出的列表,并满足如果
发现匹配...
文件存在
命令总是适用于本地文件系统。如果你想检查一个远程系统是否有一个文件,你必须 exp_send
它的一些说明来做检查。不幸的是,我不能完全告诉你在说什么,所以我不能真正的建议如何去做。
break
之后放置文件复制
行,否则它将再次绕过循环。你可能不希望这样做!while {true} {
if { [file exists $file_name] == 1} {
exp_send "copy file.txt destination \r"
puts " File copied!"
}
puts "File Not copied"
}
[file exists $file_name]
and I always end up with 0. But I know for a fact that the file exists in the current directory. Any suggestions?dir
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 if
when a match was found ...file exists
command always works with local filesystems. If you want to check whether a remote system has a file, you'll have to exp_send
it some instructions to do the check for you. Unfortunately, I can't quite tell what you're talking to from your description, so I can't actually advise how to do it.break
after that puts "File copied"
line otherwise it will all go round the loop again. You probably don't want that!