Networking without programming or using netcat and pipes to create X11 window
hereket.com
hereket.com
I mean you're not using unix sockets, but you can avoid the whole fifo <-> netcat <-> socket mess, by just doing:
exec 3>/dev/tcp/127.0.0.1/6001 #(first display)
and then just using echo -n "something something" >&3
And if you want to disconnect: 3<&-
Tools removed from the list: nc, mkfifoAnd I'd also do the "append_file" trick a little bit different:
declare -a SEND_BUFFER=()
SEND_BUFFER+=($'\x1') # create window command ID
SEND_BUFFER+=($'\x0') # depth
and so son. Bash has this special notation $'' that creates the escaped values when you use it (Check the "QUOTING" section in the man page). So echo -e "\n"
is the same as echo $'\n'
The difference is that you can add $'\n' to an array and then later do something like this: IFS=""
echo "${SEND_BUFFER[*]}"
unset IFS
This will output SEND_BUFFER as a "string" w/o any additional spaces or other separators.So, this:
declare -a foo=(a b c d e f)
printed like this: IFS=""; echo "${foo[*]}"; unset IFS;
turns into this: abcdef
You could use associative arrays and then assign names to the values, but the order of the entries is not stored and so you'd require a function that would build the string needed.$0.02
You could still use the array but instead of using the special quotes, just use single quotes like '\x0' and later echo -e to get your results.