avoiding escaping chars in exec commands
From: Tennis Smith (tennis_smith_at_yahoo.com)
Date: 10/31/03
- Previous message: TingChong: "Re: create a single self-contained standalone expect binary on solaris 8"
- Next in thread: Glenn Jackman: "Re: avoiding escaping chars in exec commands"
- Reply: Glenn Jackman: "Re: avoiding escaping chars in exec commands"
- Reply: Cameron Laird: "Re: avoiding escaping chars in exec commands"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Oct 2003 17:47:17 -0800
Hi,
I sometimes have to do relatively complex interactions with other
tools inside tcl. They are accessed using "exec".
But, often the tools being used have chars in the invocation which are
special to tcl. So far, I simply escape the chars with a "\".
That works, but causes some pretty ugly source code. For example, if
I want to do something like this from tcl:
awk '/cmd=/ { printf("%s %s %s %s", $1,$2,$8,$7); for (i = 14; i < NF;
i++) printf( " %s",$i); print "" }' aaa_raw > blit
I have to make it look like this in the source file code fragment:
if [catch {exec /usr/bin/sh -c \
"awk '/cmd=/ \
{ printf(\"%s %s %s %s\", \$1,\$2,\$8,\$7); \
for (i = 14; i < NF; i++) printf( \" %s\",\$i); \
print \"\" \
}' $raw_file > $raw2_file" \
} err] {
puts stderr "CapAAA-003: $err"
exit 0
}
Is there any way to avoid using the "\" char everywhere and passing
the whole thing at once?
TIA,
-Tennis
- Previous message: TingChong: "Re: create a single self-contained standalone expect binary on solaris 8"
- Next in thread: Glenn Jackman: "Re: avoiding escaping chars in exec commands"
- Reply: Glenn Jackman: "Re: avoiding escaping chars in exec commands"
- Reply: Cameron Laird: "Re: avoiding escaping chars in exec commands"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|