I wanted to make two pipes for a netcat server that inputs text into the server, and one that outputs text from the server. I have the server running in a seperate script with the input and output pipes. Another script (that I haven't made yet) reads the output from the netcat server using the input pipe, then sends data into the output pipe. The whole time this is happening, a client is sending data to the server, and the script I haven't made reads the data sent from the client on the server, then outputs data into the server, which goes to the client. The server script doesn't recieve data from the client when I add an output or input pipe, and it does not respond to data sent into the input pipe. I don't know why this happens, so if someone could show me how to do it, that would be great.
#!/bin/bash mkfifo in mkfifo out sudo nc -lk 22 <in >out #Yes, I know I can run this in background, but I don't #+want to do that yet.
#!/bin/bash while [ 1 ] do nc localhost 22 done #I know this block looks odd, but it allows the client to continue #+communicating with the server, even after an EOF.
Theoretical server handling script:
#!/bin/bash #This script is run after the server script is run in another console. while [ 1 ] do in="$(cat out)" #The script will be stuck here until there is output from the "out" pipe if [ $in = "blah" ] then echo "blah to you, too." >in #Here, the echo output should be sent to the client from the server fi #I can add a lot more here after I get this sorted out done