Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have installed ircd-hybrid on my Ubuntu Server (192.168.1.2, example.com).
We use #teamchannel to communicate inside the team.

The question is: how can I send some short message from example.com to #teamchannel from the bash script? e.g. example.com: Alert! The server is rebooting now

Edit:

I have found perl script which does exactly what I needed.

share|improve this question
add comment

3 Answers

up vote 7 down vote accepted

use console irc client

apt-get install ii
ii -i /tmp -s 192.168.1.2
echo "/PRIVMSG #teamchannel example.com: Alert! The server is rebooting now" > /tmp/irc/in
share|improve this answer
    
Thanks, but this does not work for me. After ii the shell waits, when I end the command with &, the second command executes but without message. –  takeshin Sep 21 '10 at 13:50
    
red the 'out' file to debug problem: find irc directory(/tmp/SERVERNAME),cd /tmp/SERVERNAME and cat out,then echo message and read out. –  bindbn Sep 21 '10 at 20:49
add comment

Without installing ii:

echo -e 'USER bot guest tolmoon tolsun\nNICK bot\nJOIN #channel\nPRIVMSG #channel :Ahoj lidi!\nQUIT\n' \
| nc irc.freenode.net 6667
share|improve this answer
    
add \nQUIT at the end of the list of commands to quit right after sending the one message –  Walter Heck Dec 23 '11 at 10:10
add comment

One solution would be to use expect to script communication with the IRC server using a telnet client.

share|improve this answer
    
Do I need expect when I want to send the message from the same machine where the IRC server is installed? –  takeshin Sep 21 '10 at 13:24
    
you do.. the above solution would work well with expect. –  Crankyadmin Sep 21 '10 at 14:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.