tcl question: Exec

Roger Oberholtzer roger
Mon May 17 11:57:30 PDT 2004


Yipes! Use the tcl 'file' command! It is platform independent. There is
even a command to convert a file name to the local convention (forward
or backward slashes and the like are 'corrected' by the command, which
is 'file nativename´). 

if [file exists myFile] {

	yada yada yada
}

The man page should be:

	man n file

No need for the exec on this one. Be aware that if you use tcl to do
things, you are building in platform independence. Usually not a bad
thing.

Want to know all the files in a directory with the extension .blb?

set blbfiles [glob *.blb]

Works on all platforms. 


On Sun, 2003-12-28 at 22:08, Joel Hammer wrote:
> I want to test if a file exists using tcl by calling linux (bash) functions.
> 
> These commands give the following:
> 
> ======================
> set d [ exec echo OK]
> This sets d to OK
> ======================
> 
> =====================================
> set d 0
> set d [ exec \[ -e /home/jlh/junk \] ]
> The second command resets d to null.
> ======================================
> 
> ================================================
> set d [ exec \[ -e /home/jlh/junk \] && echo OK ]
> This command fails with a missing bracket error.
> =================================================
> 
> I would like to know why the last command fails.
> 
> Any insight appreciated,
> 
> Joel
> 
> _______________________________________________
> Linux-users mailing list
> Linux-users at smtp.linux-sxs.org
> Unsubscribe/Suspend/Etc -> http://smtp.linux-sxs.org/mailman/listinfo/linux-users
> 




More information about the Linux-users mailing list