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
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..
% puts stdout "" | 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.

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

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

Posted by neo (The Architect), 2 May 2005
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

This page is a thread posted to the opentalk forum at 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., 2015: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: • WEB: • SKYPE: wellho