I want Tcl to talk to an application. This application has no
communication mechanisms. It isn't designed to talk at all except
that it can write data to the disk. It can also read from the disk.
So I did a little kludge. The application keeps writing to /dev/shm
while Tcl keeps reading that file. Sometimes, Tcl writes to another
file that the application can read. OK, they are talking.
But it's an ugly hack and I am struggling with the idea of keeping
tabs on what has been read, I mean, what lines/messages have been
properly delivered and must be removed from the queue, besides the
problem of deleting content from a file that is being written to all
the time. And I know that Tcl is very good at sockets, which seems interesting but I'm not sure it would be useful in my current
situation. Would it?
What approach would you recommend to make my communication system
smoother?
Can the 'other application' be asked to read/write to/from standard
input and output?
If it insists on "a file" can a Unix named pipe file be substituted for
the file it expects? Read the "mknod" Linux manual page for how to
create a named pipe.
On Fri, 14 Apr 2023 19:32:02 -0000 (UTC), Rich wrote:
Can the 'other application' be asked to read/write to/from standard
input and output?
No. I was hoping someone would come up with some kind of trick that would make some kind of "virtual" pipe or something. Or something. I don't know.
If it insists on "a file" can a Unix named pipe file be substituted
for the file it expects? Read the "mknod" Linux manual page for how
to create a named pipe.
Yes, I can have named pipes. I've had them, but have forgotten what
it was like. Anyway, is there any specific Tcl angle to this
approach or is it just named pipes being named pipes?
Tcl sockets do not fit my case, I suppose?
On Fri, 14 Apr 2023 19:32:02 -0000 (UTC), Rich wrote:
Can the 'other application' be asked to read/write to/from standard
input and output?
No. I was hoping someone would come up with some kind of trick that would make some kind of "virtual" pipe or something. Or something. I don't know.
If it insists on "a file" can a Unix named pipe file be substituted for
the file it expects? Read the "mknod" Linux manual page for how to
create a named pipe.
Yes, I can have named pipes. I've had them, but have forgotten what it
was like. Anyway, is there any specific Tcl angle to this approach or is
it just named pipes being named pipes?
Tcl sockets do not fit my case, I suppose?
Can the 'other application' be asked to read/write to/from standard
input and output?
No. I was hoping someone would come up with some kind of trick that would >make some kind of "virtual" pipe or something. Or something. I don't know.
If it insists on "a file" can a Unix named pipe file be substituted for
the file it expects? Read the "mknod" Linux manual page for how to
create a named pipe.
Yes, I can have named pipes. I've had them, but have forgotten what it
was like. Anyway, is there any specific Tcl angle to this approach or is
it just named pipes being named pipes?
Tcl sockets do not fit my case, I suppose?
There is a tcl-fuse package (https://wiki.tcl-lang.org/page/tcl-fuse).
In theory you could have the "other application" read & write its files
from a virtual filesystem served by tcl-fuse, in which case you would
have Tcl procedures called whenever it tried to read or write, and could serve up whatever seemed appropriate for input, and do whatever you wanted with the output.
I want Tcl to talk to an application. This application has no
communication mechanisms. It isn't designed to talk at all except
that it can write data to the disk. It can also read from the disk.
What approach would you recommend to make my communication
system smoother?
There is a tcl-fuse package (https://wiki.tcl-lang.org/page/tcl-fuse).
In theory you could have the "other application" read & write its files
from a virtual filesystem served by tcl-fuse, in which case you would
have Tcl procedures called whenever it tried to read or write, and could serve up whatever seemed appropriate for input, and do whatever you wanted with the output.
There is a tcl-fuse package (https://wiki.tcl-lang.org/page/tcl-fuse).
In theory you could have the "other application" read & write its files
from a virtual filesystem served by tcl-fuse, in which case you would
have Tcl procedures called whenever it tried to read or write, and could
serve up whatever seemed appropriate for input, and do whatever you wanted >> with the output.
Sorry to bother you all with this but I am struggling too much to make any >decent progress.
If I understand it correctly, I need to be able to write files in the
virtual file system so I can only use FTP or MK4 because all others are >read-only. But I don't see how FTP would work since it's not really FTP,
so I guess I will have to use MK4. Correct so far?
Now, am I supposed to create a new MK4 VFS? An empty one?
And how do I connect that to tcl-fuse? I ran some commands and fuse shows >that a directory is mounted, but it complains that it is "not connected
on the other end." How do I connect the two things?
Can someone please advise with more detail?
On 15 Apr 2023 04:40:14 GMT, [email protected] (Ted Nolan ) wrote:
There is a tcl-fuse package (https://wiki.tcl-lang.org/page/tcl-fuse).
In theory you could have the "other application" read & write its files
from a virtual filesystem served by tcl-fuse, in which case you would
have Tcl procedures called whenever it tried to read or write, and could
serve up whatever seemed appropriate for input, and do whatever you wanted >> with the output.
Sorry to bother you all with this but I am struggling too much to make any decent progress.
If I understand it correctly, I need to be able to write files in the
virtual file system so I can only use FTP or MK4 because all others are read-only. But I don't see how FTP would work since it's not really FTP,
so I guess I will have to use MK4. Correct so far?
Now, am I supposed to create a new MK4 VFS? An empty one?
And how do I connect that to tcl-fuse? I ran some commands and fuse shows that a directory is mounted, but it complains that it is "not connected
on the other end." How do I connect the two things?
Can someone please advise with more detail?
The manpage provides a basic example (https://tcl-fuse.sourceforge.net/#EXAMPLE) that you should look over.
Once you create the proper code, you'd have the code create a 'mount'
at the location where you want the virtual filesystem to appear (note
the line near th end of the example beginning with 'hello' That
creates the 'example' vfs in the filesystem at examples/mnt (both of
which need to exist in the current directory where you run this code).
On Mon, 17 Apr 2023 22:12:27 -0000 (UTC), Rich wrote:
The manpage provides a basic example
(https://tcl-fuse.sourceforge.net/#EXAMPLE) that you should look over.
Once you create the proper code, you'd have the code create a 'mount'
at the location where you want the virtual filesystem to appear (note
the line near th end of the example beginning with 'hello' That
creates the 'example' vfs in the filesystem at examples/mnt (both of
which need to exist in the current directory where you run this code).
So it seems that the VFS in this case never really contains anything
because it doesn't even exist as a file.
It is a very different animal from a loop device for example.
So it gets mounted somewhere in the "host" filesystem and if someone
asks to see the content of the directory, it really pretends to have
a file named "hello" and if someone attempts to open the file, it
spits out some text as if it was the content of the file that didn't,
doesn't and will never exist, not too differently from a magician's
assistant sitting under the table and passing items to the magician
during the act, or those videos with the head of a dog and the hands
of someone pretending to be the dog's hands.
So far, I am correct. Right?
Now, I ran the example and opened the directory. Sure enough, there
was the "hello" file. I opened a terminal session and ran this:
$ tcl/editor/fuse> echo touch > hi.txt
An error occurred while redirecting file 'hi.txt'
open: Function not implemented
$ tcl/editor/fuse> touch hi.txt
touch: setting times of 'hi.txt': Function not implemented
So why is "open" not implemented? The code specifies a proc for "Open."
I do notice the different case, but the create command line is:
fuse create hello -getattr Getattr -readdir Readdir -open Open -read Read -write Write
* Note that I also have a Write proc. I added it. But it only returns,
doing nothing.
So I fully expect any "open" hook (or whatever it's called) to be handled
by the "Open" proc. But it says "not implemented." What does that really mean?
Then 'touch' doesn't work because, again, "not implemented." What exactly
is "not implemented" and how do I "implement" it?
My first reaction to this would be to write a "Touch" proc, but the
same problem with "Open" tells me that I must be entertaining some
wrong concept again (the first time was mistaking Tcl VFS for some
kind of loop device).
More light, please?
$ tcl/editor/fuse> echo touch > hi.txt
An error occurred while redirecting file 'hi.txt'
open: Function not implemented
$ tcl/editor/fuse> touch hi.txt
touch: setting times of 'hi.txt': Function not implemented
Rich answered a plan what you will have to do to make it work. There is
some serious work to do before you reach your goal of remote-controlling another application via a VFS. I don't want to discourage you, but maybe
if you reveal what application you want to control, then maybe someone
can suggest another way or a similar program which does the same, but is
more easily scriptable.
Happy hacking,
Christian
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 07:48:36 |
| Calls: | 12,100 |
| Files: | 15,003 |
| Messages: | 6,517,941 |