Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Basically it is a piece of Tcl code. I was learning how to run Unix programs with Tcl scripts using open and exec commmands.The open command returns a file descriptor which in this example, is assigned to variable nt.I have learned that "If the first character of fileName is not | then the open command opens a file: fileName gives the name of the file to open. If the first character of fileName is “|” then the remaining characters of fileName are treated as a list of arguments that describe a command pipeline to invoke, in the same style as the arguments for exec. In this case, the channel identifier returned by open may be used to write to the command's input pipe or read from its output pipe, depending on the value of access. If write-only access is used (e.g. access is w), then standard output for the pipeline is directed to the current standard output unless overridden by the command. If read-only access is used (e.g. access is r), standard input for the pipeline is taken from the current standard input unless overridden by the command."
What I dont understand is that what is meant by Command pipeline and channel identifier in above explanation. Also another example
set fd1 [open "simpleinput" "r"] ;# open the file for reading
set fd5 [open "|simple1" "r"] ;# Read the stdout of simple1 as fd5
set fd2 [open "reldirect/simpleoutput" "w"] ;# open the file for writing
set fd6 [open "|simple2" "w"] ;# Writes to fd6 are read by simple2 on its stdin
How does second statement differ from first one in each pair.
simpleinput is a file in the current working directory, and you are creating a tcl channel identifier fd1, which can now be used to read from that file.
set fd5 [open "|simple1" "r"] ;
simple1 is a program or script that will be executed, and the standard output from that program (the stream that would be sent to the terminal if you invoked the program directly from the command line) can now be read from tcl channel identifier fd5.
set fd2 [open "reldirect/simpleoutput" "w"] ;
simpleoutput is a file in directory reldirect below the current working directory, and you are opening that file (which will be created if it does not already exist) to receive any data that you send to tcl channel identifier fd2.
set fd6 [open "|simple2" "w"] ;
simple2 is again a program or script that will be executed, and whatever you write to tcl channel identifier fd6 will be sent to that program's standard input.
Last edited by rknichols; 04-12-2011 at 09:06 AM.
Reason: correct confusion of tcl channel identifiers with file descriptor numbers
Actually there were multiple errors in what I wrote. fd1, fd2, etc., are arbitrary tcl channel identifier names that bear enough resemblance to file descriptor numbers to get me confused. To make matters worse, file descriptor numbers start at 0 for "stdin" and 1 for "stdout", so my description of the standardized file descriptor numbers was flat out wrong. What I originally posted was probably close enough to get you on the right path, but I've made corrections to avoid confusing anyone else who comes across this.