Question

Running Debian 7. Is it possible that when a program opens a file we can give it output from a currently running file.

Example: We have a C/Java program running. This is (attached)? to file /etc/motd as an example. When ssh or any other program goes to read /etc/motd the C/Java program provides output instead. So instead of the file being read from disk it is being read from the C/Java program.

Was it helpful?

Solution

You would create /etc/motd as a special device file, not as a regular text or binary file. Then, you would attach your program to the device file with a pipe and have it waiting for input. Once input was received the program would then process the data and do the commands required. Items to refer to are: mknod and | (pipe).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top