Preparing a Mac for Perl's Net::Growl

Preparing a Mac for Perl's Net::Growl

Now that we’ve covered how to use Perl to send notifications to Growl, the immediate next question is How do I send notifications from Linux? Granted, that might not have been your immediate question, but speaking as someone who manages several Linux servers, it was certainly mine.

Net::Growl is a Perl module that lets you send Growl notifications over the network. Installation is very straightforward. You might also need to install Pod::Usage. On your Linux box:

$ sudo perl -MCPAN -e shell $ install Net::Growl $ install Pod::Usage

I don’t recall Net::Growl requiring any prerequisites so the above should have you ready to go. The Net::Growl package includes example.pl, which shows different methods to make calls. I rewrote this script as net-growl.pl, which you can download here. Just rename net-growl.txt as net-growl.pl. The script is commented fairly well. Running the following will give you all the options.

perl ./net-growl.pl

Once you have that script ready to go, we need to check the Mac system which will receive the Growl notifications. Go to System Preferences -> Security -> Firewall. If your system is set to Allow all incoming connections and you’re fine with this setting, you’re done with this and only need to configure Growl. I’m not comfortable with any incoming connection to any application, so I have mine set to Set access for specific services and applications, as you can see below.

System Preferences :: Security :: Firewall

Click the + button, then navigate to /Library/PreferencePanes and choose Growl.prefPane.

/Library/PreferencePanes/Growl.prefPane

Once done, make sure Allow incoming connections is selected for it, as has been done for SimplifyMedia and lynx in the first picture.

Now go to System Preferences -> Growl -> Network. Click the Listen for incoming notifications box and the Allow remote application registration box. Finally, enter a password in the Server Password box.

System Preferences :: Growl :: Network

Now your Mac should be ready.

From your Linux system, run net-growl.pl as shown below. Just replace 127.0.0.1 with the IP address of your Mac system and seekrit with the password you assigned to Growl on your Mac.

$ perl ./net-growl.pl -server=127.0.0.1 -password=seekrit

The application should register itself with Growl and display a message your Mac. You can now go to System Preferences -> Growl -> Applications, click on the net-growl.pl entry, click Configure…, then set the Application’s Display Style to Prowl. Running the net-growl.pl again should result in the message being sent to your iPhone.

And that, as they say, is that. Have fun!