1

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.

Server script:

#!/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.

Client script:

#!/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
SpecialBomb
  • 1,968
  • didn't you ask this question before? i know i answered a question about a networked bash and how ncat might be used to set the shell up as a server. remember? – mikeserv Jan 05 '16 at 02:29

0 Answers0