As the basis for a larger script I'm trying to write I'm trying to basically implement a basic netcat client in bash. My current script techincally works, it looks like this:
#!/bin/bash
exec 3<>/dev/tcp/$1/$2
cat <&3 &
cat <&1 >3
The problem with it is that it leaves a hanging cat process which needs to be killed, but I can't figure an automatic way to do so, and manually running pkill cat
doesn't really seem sporting.