Hey, Rafael!

Sending messages to an IRC server from a shell script (Bash)

Introduction

Rafael Fonseca

Rafael Fonseca


snippet irc

Sending messages to an IRC server from a shell script (Bash)

Posted by Rafael Fonseca on .
Featured

snippet irc

Sending messages to an IRC server from a shell script (Bash)

Posted by Rafael Fonseca on .

This is a helpful little script I found on the net and modified to work around an issue with fast CPUs and slow IRC servers. If you find yourself needing to send messages from a shell script to an IRC server but keep coming against the 451 PRIVMSG: You have not registered error, inserting a sleep between the USER and PRIVMSG commands does the trick.

#!/bin/bash -x
(
echo NICK backoffice
echo USER backoffice 8 * : Notifier
sleep 1
# echo 'JOIN #netops'
echo 'PRIVMSG #netops' $1
echo QUIT
) | nc 127.0.0.1 6667
Rafael Fonseca

Rafael Fonseca

View Comments...