Coding a Jabber Bot in Perl
I finally got it to work and it is not so difficult with the right packages (Net::XMPP) and parameters …
#! /usr/bin/perl</code>
use strict;
use warnings;
use Net::XMPP;
#################
# Config params #
#################
my $hostName = 'jaim.at';
my $portNumber = 5222;
my $componentName = 'jaim.at';
my $userName = 'totosk1008';
my $passWord = 'totosk1008';
my $resource = 'NiceLittleBot';
my $tls = 0;
my $connectionType = 'tcpip';
my $debugLevel = 0;
# Create the client
my $bot = new Net::XMPP::Client(debuglevel => $debugLevel);
$bot->SetCallBacks(
onconnect => &connectedCB, # gets called when connected
onauth => &authedCB, # when authenticated
ondisconnect => &disconnectedCB, # when disconnected
);
$bot->SetMessageCallBacks( # callback for messages
chat => &messageCB, # chat-type messages
);
$bot->Execute( # entering the main loop
hostname => $hostName,
port => $portNumber,
tls => $tls,
username => $userName,
password => $passWord,
resource => $resource,
register => 0,
connectiontype => $connectionType,
);
##############
# Callbacks #
##############
sub messageCB { # call back implementing the echo
my $sid = shift;
my $msg = shift;
my $from = $msg->GetFrom;
my $to = $msg->GetTo;
my $name;
my $data;
print "From : ", $from, "\n",
"Subject : ", $msg->GetSubject, "\n",
$msg->GetBody, "\n";
$name = $msg->GetBody;
$data = $msg->GetBody;
print ">>$name<<\n";
print $data, "\n";
$bot->MessageSend(
to => $from,
from => $to,
resource => 'Gaim',
type => $msg->GetType,
subject => $msg->GetSubject,
body => $data,
);
}
sub connectedCB {
print "Connected\n";
}
sub authedCB {
print "Authed\n";
$bot->PresenceSend;
}
sub disconnectedCB {
print "Disconnected\n";
}
Add disk in an AIX machine
few useful commandes :
- lsdev : allows you to list the hardware in your machine AIX knows about. For example
lsdev -C | grep scsi
will list all the SCSI interfaces of your machine
- cfgmgr : lets you change the hardware settings. For example
cfgmgr -l scsi0
will rescan the scsi0 bus to find and configure any newly attached SCSI peripheral.
About
My name is Stéphane Kattoor.
I live in France near Paris.
I work as a Systems Engineer and I am a computer hobbyist.
My main interests are around open source, operating systems (mostly Unix but Windows as well), coding (mostly in Perl these days), home automation, and many other things …
This site is a placeholder for things I learn/discover during my work or hobbies and I consider (hopefully) worth sharing.
me <- proud ! ;-)
I finally finished it (though I expect to have to make some changes in the future …) :
Now I can setup my home automation events in MisterHouse throught my Mozilla Calendar ! The code has been submited and accepted for being integrated in MisterHouse and will be in the next release 🙂
Code is here.
Printer Setup on a Solaris 8 Workstation
Here is a little post to give a hint about setting up a printer on a Solaris 8 Workstation :
# lpadmin -p printerName -s printServer # lpadmin -p printerName -D "Printer description text" # lpadmin -d printerName # lpstat -p printerName
and then check you can print with :
# echo test | lp
Checkout this great Solaris 8 docs repository at Sun.com.
Sun T3 StorEdge : Batteries refresh …
if you get this kind of “error” :
Dec 14 02:36:31 hostname StoreX (Dec 14, 2005 2:36:31 AM FQDN):P3:System hostname-t3 (XX.XX.XX.XX) - Unit-unit-1 - Power-Module-2 (u1pcu2) : Power supply unit has switched to battery. Fru ID: u1pcu2, Model: 300-1454-01(50), Serial Number: XXXXXX<br /> Dec 14 02:58:31 hostname StoreX (Dec 14, 2005 2:58:30 AM FQDN):P3:System hostname-t3 (XX.XX.XX.XX) - Unit-unit-1 - Power-Module-2 (u1pcu2) : The FRU has some error. Fru ID: u1pcu2, Model: 300-1454-01(50), Serial Number: XXXXX
then be aware that a T3 performs a battery refresh every so and then (this is by default every 28 days, but can be modified in /etc/schd.conf). This battery refresh can provoke this kind of error messages which are no error at all …
Sun T3 StorEdge : Identifying a failure
when logged on the T3, you can see the state of each FRU with the command
fru stat
Example :
hostname-t3:/:fru stat CTLR STATUS STATE ROLE PARTNER TEMP ------ ------- ---------- ---------- ------- ---- u1ctr ready enabled master - 32.5 DISK STATUS STATE ROLE PORT1 PORT2 TEMP VOLUME ------ ------- ---------- ---------- --------- --------- ---- ------ u1d1 ready enabled data disk ready ready 34 v0 u1d2 ready enabled data disk ready ready 30 v0 u1d3 ready enabled data disk ready ready 43 v0 u1d4 ready enabled data disk ready ready 31 v0 u1d5 ready enabled data disk ready ready 39 v0 u1d6 ready enabled data disk ready ready 31 v0 u1d7 ready enabled data disk ready ready 32 v0 u1d8 ready enabled data disk ready ready 30 v0 u1d9 ready enabled standby ready ready 31 v0 LOOP STATUS STATE MODE CABLE1 CABLE2 TEMP ------ ------- ---------- ------- --------- --------- ---- u1l1 ready enabled master - - 27.5 u1l2 ready enabled slave - - 30.0 POWER STATUS STATE SOURCE OUTPUT BATTERY TEMP FAN1 FAN2 ------ ------- --------- ------ ------ ------- ------ ------ ------ u1pcu1 ready enabled line normal normal normal normal normal u1pcu2 ready enabled line normal normal normal normal normal
Parsing an ICal file with Perl
I finally almost got it …
Here is a code snippet for parsing and showing pieces of an ICal file :
use strict; use warnings; use Data::ICal; use Data::ICal::DateTime; use DateTime; my $cal = Data::ICal->new(filename => 'holidays.ics'); my @events = $cal->events(); foreach my $event (@events) { print "summary:", $event->property('summary')->[0]->value, "n"; print "dtstart:", $event->start, "n"; print "dtend:", $event->end, "n"; } print DateTime->now, "n";
What I want to do ? Drive my home automation events with my Mozilla Calendar !! I’ll soon be there, if I gather enough time to do it !
Home automation
This is related to one of my geek hobbies : I am playing with home automation.
Here is what I use :
- Technology : x10
- Software : MisterHouse
- Hardware : a CM11, few AM12, LM12 etc
This is really great since it allows you to control anything in your house (lights, washing machine, heaters, …) from your computer, while still being fairly simple.
Using MisterHouse requires to know at least a little bit of Perl to get the most out of it, though.
First post !
Hello,
My name is Stephane Kattoor, I work as an IT Engineer, and I created this blog with the idea to use it to store the little technical tips or hints I find in my every day work … with the hope it will help me and perhaps some others as well !
Come from time to time, I plan to keep it updated !
Stephane