Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
This week, we're updating our course layouts and descriptions. Presentation and materials always gently change over time, but just occasionally there's a need to make a step change to clear out some of the old and roll in the new. That's now happening - but over a long and complex site it's not instant and you'll see sections of the site changing up to and including 19th September.

See also [here] for status update
 
Piping commands in TCLSH

Posted by neo (The Architect), 1 May 2005
How can I pipe commands in a TCL script or in the TCL shell?

Posted by admin (Graham Ellis), 1 May 2005
Use "puts" to send the output of your script to STDOUT, then use a "|" followed by the command you want to send your output to on the command line.

Posted by neo (The Architect), 1 May 2005
Here is the output..
Quote:
% puts stdout "testfilejava.java" | sed s/"\.java"//
wrong # args: should be "puts ?-nonewline? ?channelId? string"
%



Posted by admin (Graham Ellis), 1 May 2005
Here's an example of what I meant ... using | in the shell not in Tcl.

Code:
earth-wind-and-fire:/resources grahamellis$ tclsh fred.tcl | sed s/\.java//
testf.java
earth-wind-and-fire:/resources grahamellis$ cat fred.tcl
puts stdout testf@java.java

earth-wind-and-fire:/resources grahamellis$


Posted by neo (The Architect), 2 May 2005
Ok.
So does the TCL shell (tclsh) as such support piping?

Posted by admin (Graham Ellis), 2 May 2005
The pipe character (|) has no special significance in Tcl - so, no, the Tclsh shell doesn't itself support piping.   That's why the I suggested that you use a shell pipe in answer to your first question.

You've really got two options to pipe commands in Tcl; you can follow my shell suggestion as made earlier in thsi thread, or you can use the open command with a pipe character as the first character of what would (otherwise) by the file name.   There's an example on our web site at http://www.wellho.net/resources/ex.php4?item=t209/disc_status.





This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho