I have a problem with using shell pipe and variables in Tcl exec
command. In unix shell, the following works fine.
ll -R | awk '{print $9}' | sed -e '/^$/d' -e '/\.\//d' > files.list
However, Tcl interpreter complains when this is used in the tcl exec
command, i.e.,
...
exec ll -R | awk '{print $9}' | sed -e '/^$/d' -e '/\.\//d' > files.list
....
I tried to insert backslash before the $ and single quote, neither helps.
Could someone out there gives me any hints?
Thanks!
---------
Rick W. Li
Bell-Northern Research
GSF Framework Independent Testing
ESN 395-3614
IF you are trying to recursivly get file names in the current dir and its subdirectories, then using awk to do that is an over kill.
There are many ways of solving your problem:-
A. You can include your unix command in a script file say foo and then invoke
exec foo outFileName
B. Use a simpler command like ls -r -1 | grep -v '/$'
C. Generaly I try to avoid using csh command from a tcl script, specially when
dealing with file names, one reason is due to the availability of a rich Tcl commands for file manipulation. In another words, experiment with the glob and file commands available with Tcl.
file tail [glob [glob */]*] I did not try this but !!!
Regards
/Mohammed
Hi,
I have a problem with using shell pipe and variables in Tcl exec
command. In unix shell, the following works fine.
ll -R | awk '{print $9}' | sed -e '/^$/d' -e '/\.\//d' > files.list
This might work:
exec ll -R | awk {{print $9}} | sed -e {/^$/d} -e {/\.\//d} > files.list
Ed Karrels
kar...@mcs.anl.gov