nc alternative (pure bash) (for docs)
datajerk opened this issue · 8 comments
datajerk commented
#!/bin/bash
exec 3<>/dev/tcp/termbin.com/9999 # create FD
[ -t 0 ] && echo -en $* >&3 || cat >&3 # send it
cat <&3 # get the url
exec 3<&- # remove FD (clean up)
Usage:
echo foo bar foo | bashscript
or
bashscript test 123
OS/X and Linux tested.
Alias example:
$ alias tb2="(exec 3<>/dev/tcp/termbin.com/9999; cat >&3; cat <&3; exec 3<&-)"
$ echo foobar | tb2
solusipse commented
That's awesome, thanks, I'll add it to the project's website!
solusipse commented
Added to the readme, thank you very much!
theAkito commented
When executing the above command,
I get this on the client side:
-bash: 3: Bad file descriptor
-bash: 3: Bad file descriptor
And this on the server side:
[Fiche][ERROR] No data received from the client!
Aeres-u99 commented
@theAkito Perhaps this should fix it for you,
mknod /dev/tcp c 30 36
mknod /dev/udp c 30 39
dashezup commented
fwiw, here is the equipment on zsh
tb() { zmodload zsh/net/tcp; ztcp termbin.com 9999; cat >&$REPLY; cat <&$REPLY; ztcp -c $REPLY }
caleb15 commented
If I was trying to do something like echo ruok | nc 127.0.0.1 5111
how would I do it with this alias? 🤔
martin-braun commented
Pure POSIX shell? Anyone? :)