Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
reading stdin in tcl/tk
- utrrrongeeb
- Posts: 254
- Joined: 2006-05-14 09:48
- Location: Eastern Canada
reading stdin in tcl/tk
I don't know tcl/tk, but I want to try using it for something. It needs to load about a kilobyte off stdin (from a pipe). Could someone explain how to do this?
utrrrongeeb formerly lecaro
Art #429775 on 'Etch' 4.0r0
Art #429775 on 'Etch' 4.0r0
Hi, lecaro.
I needed to shift my mental gears slightly for this because I've been doing a lot of perl lately. I had a few moments today, and I did some tcl scripting a few years ago at a networking company. I hasten to add that I didn't write as much tcl as I had written perl, and I could not have done this off the top of my head now.
You can find information like this in Brent Welch's Practical Programming in Tcl and Tk, 3rd, and other references as well. The driver script driver1 uses a here document to feed 4 lines into the tcl script t2 -- note the pipe symbol on the same line as the cat command ... cheers, drl
And when driver1 is executed, the following is produced:
I think it's a good thing to try features, and, if you run into trouble, post what you have, and ask specific questions ... cheers, drl
I needed to shift my mental gears slightly for this because I've been doing a lot of perl lately. I had a few moments today, and I did some tcl scripting a few years ago at a networking company. I hasten to add that I didn't write as much tcl as I had written perl, and I could not have done this off the top of my head now.
You can find information like this in Brent Welch's Practical Programming in Tcl and Tk, 3rd, and other references as well. The driver script driver1 uses a here document to feed 4 lines into the tcl script t2 -- note the pipe symbol on the same line as the cat command ... cheers, drl
Code: Select all
#!/bin/sh
# @(#) driver1 Send some input to tcl script in file t2.
#
# A blank line is included; some tcls might need use of eof
# function.
cat <<EOF |
one
two
three
EOF
./t2
Code: Select all
#!/usr/bin/tclsh
# @(#) t2 Demonstrate tclsh read from stdin.
set channel {stdin}
while { [ gets $channel line ] >= 0 } {
puts $line
}
Code: Select all
% ./driver1
one
two
three
["Sure, I can help you with that." -- USBank voice recognition system.
( Mn, 2.6.x, AMD-64 3000+, ASUS A8V Deluxe, 3 GB, SATA + IDE, NV34 )
Debian Wiki | Packages | Backports | Netinstall
( Mn, 2.6.x, AMD-64 3000+, ASUS A8V Deluxe, 3 GB, SATA + IDE, NV34 )
Debian Wiki | Packages | Backports | Netinstall
- utrrrongeeb
- Posts: 254
- Joined: 2006-05-14 09:48
- Location: Eastern Canada