Quote:
Originally Posted by Perderabo
vger99 has the syntax. But the direction you are taking seems to be wrong. A fd is specific to a process. Exporting a vaiable containing an fd is senseless. In your first post, when you said "function", I assumed you meant "function". A function is ksh concept and it can have locally scoped variables. A global variable is global to the script, not the environment.
First of all, vger99,
thank you. This will solve the problem that I was struggling with. I was probably wrapping myself around my own axils pretty tight because I did double up the "$" symbols, however, I was escaping the second rather than the first. Thanks again.
Secondly, Perderabo, I don't really prefer the direction I am taking either but, considering the fact that I am trying to fit this into my existing library of functions, I think that this may be acceptable. I am also considering an array (three arrays perhaps because of KSH-88) that will help me find the fds.
I'll explain the concept further to clear it up; perhaps you have a better suggestion. Judging from the examples that I have seen with your name attached, I am sure you can come up with something more elegant.
a. I have existing functions to communicate to my co-process, lets call them func_write and func_read.
b. Within these functions, I currently communicate to my co-process with print -p and read -p.
c. I want to eliminate the need to disconnect from my current database so I can communication to a new database for some sporadic lookups.
d. I thought that I could create two co-processes (hence requiring the I/O redirection) and define file descriptors for each co-process.
e. Therefore, to keep my current functions generic, I thought that I would supply a database descriptor (handle) to each function (e.g. func_write "something" database_handle_1)
f. Within the function, I would translate "database_handle_1" into a variable that was previously exported so that I can retrieve the correct fd and then use print -u${database_handle_1_stdout}
Arrays will give me the same thing but referencing dynamic variables seemed logial when I started thinking through how to implement this.
Thanks again,
Thomas