Skip to content

Instantly share code, notes, and snippets.

@jadell
Created March 15, 2011 21:22
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save jadell/871512 to your computer and use it in GitHub Desktop.
Save jadell/871512 to your computer and use it in GitHub Desktop.
Read and write to a socket using only Bash
#!/bin/bash
#
# Bash must have been compiled with this ability: --enable-net-redirections
# The device files below do not actually exist.
# Use /dev/udp for UDP sockets
exec 3<>/dev/tcp/host/port
# Write to the socket as with any file descriptor
echo "Write this to the socket" >&3
# Read from the socket as with any file descriptor
cat <&3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment