Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using shell pipe and variables in Tcl exec command

1,241 views
Skip to first unread message

Weidong Li

unread,
Aug 5, 1994, 4:21:29 PM8/5/94
to
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

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

Mohammed Shoaib

unread,
Aug 9, 1994, 1:56:34 PM8/9/94
to

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

Edward L. Karrels

unread,
Aug 11, 1994, 4:15:28 AM8/11/94
to
In article <31u709$o...@bmerha64.bnr.ca> ric...@bmerha9f.bnr.ca (Weidong Li) writes:

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

0 new messages