alright i've made a lot of progress. i figured out how to get 2 way communication by having receive run in the background however, with the way send and receive are set up its like the second one created receives from its same pipe that it sends to it just prints on the screen twice instead of printing on the screen thats supposed to be receiving. One way communication works fine and 2 way would work if i could figure out how to get it to go to a different pipe or something. I thought to keep the multiple conversations and pipes straight i would just name the pipe after the user that's being sent the message however when the recipient sends a message back it uses the same pipe and therefore just prints out twice on the same screen instead of once on the other screen. I guess its like going in a circle or something? Any ideas on how to make it send to the other pipe? Also, this all only works if the same user is logged in at 2 different places. Any ideas on how to make it work with one user sending it to another because i couldn't get any kind of communication to work user to user. Heres what i have:
send.sh the send program
#!/usr/bin/bash
if [ "$1" = "" ]
then
w | cut -f1 -d ' ';
echo "Please enter a user name";
read uname;
#uname="$1";
echo $uname;
else
uname="$1";
#echo $1;
echo $uname;
fi
echo $uname;
mkfifo $uname
#mkfifo mypipe5
cat > $uname
receive.sh the receive program
#!/usr/bin/bash
pipeName=$(echo $(whoami));
#echo "pipename after assignment is"
#pipeName="mypipe5"
echo $pipeName
echo $pipeName;
mkfifo $pipeName;
cat < $pipeName&
So basically a circle is being created if send.sh is run after receive.sh is run because since the user names are both the same the pipes are both the same also. Is there a way to append like a 1 or something at the end of one of them so the names are different? However, wouldn't this make it impossible to receive for one user because the pipe that is being wrote to and read from would be different?