You are not logged in.
Pages: 1
I was wondering what would be the simplest way to make 2 programs interract through standard I/O. I mean something like a two-way pipe: first program outputs something, second one reads it and outputs something back to the first one... The idea is to automate evaluation of solutions to some simple user interactive problems.
Has anyone done something like this? Could I do it with simple Bash or should I use something more powerful like Python or even C++? Those are the three languages I can use.
Offline
Unix sockets?
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
Unix sockets?
That sounded far too complicated for what I was going for, so I googled it a bit and found out how great bash named pipes are. Still, I was messing around with it for a lot of time and got nowhere. Then I got lucky and found a post from some forum where this guy had a brilliantly simple solution for connecting two commands (or functions, programs...) with one standard pipe and one named pipe:
fifo='/tmp/myfifo'
mkfifo $fifo
first <$fifo | second >$fifo
rm $fifo
I think I'm getting more and more in love with bash!
Offline
A fifo has a delay though, right?
Offline
I don't know. What exactly do you mean? I am new to bashing, so it's quite possible that there's some problem I didn't notice, but this solution seems to be working great for now.
Offline
I forgot what it was exactly, the delay was probably just coming from tail -f.
Offline
Pages: 1