home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.tcl
- Path: sparky!uunet!think.com!ames!decwrl!decwrl!parc!welch
- From: welch@parc.xerox.com (Brent Welch)
- Subject: Re: Running Shell commands
- Message-ID: <welch.721414106@corvina>
- Keywords: Shell, Pipe, TCL/TK, exec, eval
- Sender: news@parc.xerox.com
- Organization: Xerox PARC
- References: <1992Nov06.042401.3241@bnr.ca> <1992Nov6.125342.15092@walter.bellcore.com>
- Date: 10 Nov 92 16:48:26 GMT
- Lines: 40
-
- bytor@grumpy.bellcore.com (Ross Huitt) writes:
-
- >In article <1992Nov06.042401.3241@bnr.ca>, tdoan@bnr.ca (Tuan Doan) writes:
-
- >|> Hello,
- >|>
- >|> I am trying to get the following shell command to work inside TCL/TK and
- >|> is having great difficulty. If anyone know the solution to this, please
- >|> post.
- >|>
- >|> pr -h '[tdoan@crchh404] /bnr/file1' /bnr/file1 | ipr -D"pageduplex off"
-
- >Try something like:
- > exec {pr -h '[tdoan@crchh404] /bnr/file1' /bnr/file1 | ipr "-Dpageduplex off"}
-
- >The '{}' will protext you from executing the regular expression and you'll have to
- >move the " in the arg to ipr because of the way Tcl handles strings.
-
-
- The above suggestion won't work because exec will try to run a program
- named "pr -h ...", not pr. I've just done:
-
- exec pr -h {[welch@corvina] /tmp/foo} /tmp/foo | lpr -P snoball
-
- The braces will cause pr to get an argv[2] that is "[welch@corvina] /tmp/foo"
- There is no need for eval in this simple case.
- The following little procedure also works.
-
- proc printit { user file } {
- set header "\[$user\]"
- exec pr -h "$header $file" $file | lpr -P snoball
- }
-
- The trick to remember here is that inside the double quotes there is
- only a single level of substitution. It doesn't matter that the value
- of $header looks like a TCL expression. Only the variable substitution
- occurs, and again pr gets an argv[2] of "[welch@corvina] /tmp/foo"
- --
-
- Brent Welch
-