Created
May 2, 2014 00:38
-
-
Save vivien/3b1c2efb80f3f3dde001 to your computer and use it in GitHub Desktop.
irccat - Using netcat with an IRC channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Copyright 2014 Vivien Didelot <[email protected]> | |
# Licensed under the terms of the GNU GPL v3, or any later version. | |
NICK=irccat42 | |
SERVER=irc.freenode.net | |
PORT=6667 | |
CHAN="#irccat" | |
{ | |
# join channel and say hi | |
cat << IRC | |
NICK $NICK | |
USER irccat 8 x : irccat | |
JOIN $CHAN | |
PRIVMSG $CHAN :Greetings! | |
IRC | |
# forward messages from STDIN to the chan, indefinitely | |
while read line ; do | |
echo "$line" | sed "s/^/PRIVMSG $CHAN :/" | |
done | |
# close connection | |
echo QUIT | |
} | nc $SERVER $PORT | while read line ; do | |
case "$line" in | |
*PRIVMSG\ $CHAN\ :*) echo "$line" | cut -d: -f3- ;; | |
#*) echo "[IGNORE] $line" >&2 ;; | |
esac | |
done |
What about when a server pings, and waits for a pong?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome.