public
Last active

Speak the IP address of your linux machine. Perfect for Raspberry PIs or other headless servers with audio output. Just plug in a speaker or earphones and wait to be told the IP address to ssh to!

  • Download Gist
IPspeak.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#!/usr/bin/perl
 
# IPspeak.pl
 
# speak the IP address of this machine, e.g. for a Raspberry Pi with no screen.
# requires "espeak" (sudo apt-get install espeak)
 
# Andy Stanford-Clark (@andysc)
# 18-May-13
 
# give it a chance to get an IP address at boot-up
sleep 10;
 
while (1)
{
# look at wireless first, and say that, even if there's also ethernet
$IP = `ifconfig wlan0 | grep 'inet addr'`;
$text = "wireless";
 
if (!$IP)
{
# if no wireless, look for ethernet
$IP = `ifconfig eth0 | grep 'inet addr'`;
$text = "ethernet";
}
 
if ($IP =~ /inet addr:(.*?) /)
{
# insert spaces between all characters
@characters = split(//,$1);
$text .= " address " . join(" ",@characters);
 
# change dots to, um, dots
$text =~ s/\./dot/g;
}
else
{
$text = "no IP address";
}
 
print "'$text'\n";
system("espeak '$text'");
 
# wait a minute before doing it again
sleep 60;
}
Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Speak the IP address of your linux machine.
 
Perfect for Raspberry PIs or other headless servers. Just plug in a speaker or earphones and wait to be told the IP address to ssh to!
Requires "espeak" - sudo apt-get install espeak
 
Make IPspeak.pl executable:
chmod +x IPspeak.pl
 
Run it automatically at startup (otherwise it's rather pointless, as you'd have to know the IP address to log-in to start it ;) )...
Add to /etc/rc.local (e.g. sudo vi /etc/rc.local ) above the "exit 0", the line:
su - pi -c /home/pi/IPspeak.pl
(note the spaces)
 
If you want to stop IPspeak (once you've logged in to the IP address it's told you), type:
pkill IPspeak

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.