Simple Perl Ping Script – Local and Remote

A Perl Beginner Template to play with
This is just a little script I slung together to play with LWP::SIMPLE and NET::PING Perl modules. The main idea is to get info from a website (, clean it up and use it for either input or output. I also wanted a few bits of code for user (choice) input as well. It’s another base that a beginner can build on.

Ask and Go Fetch
It asks for input and based on the reply performs one of two different tasks and offers some info. Nothing more, nothing less. However, if you look at the actions it performs, you will see that this basic script can be adapted to acquire any type of information from any website, which in turn can be used for a completely different script.

# This script will get a local or remote IP, ping the address and tell you if the ADSL line is up
# By Rich Scadding  @
# Ping Module
use Net::Ping;
# Get Html
use LWP::Simple;# Debian apt-get install libwww-perl
# Debugging
#use strict; (commented as it throws up errors)
use warnings;

# Check if an ip adress is alive
print “Which IP shall I check? Yours [1] Other [2]: “;
my $answer = ;
chomp $answer;
# If the idiot can’t type, tell them!
die “No, only press 1 or 2. Try again!\n” if ($answer ne “1” and $answer ne “2”);
# 2 needs an IP from the user
if ($answer eq “2”) {
print “Type the IP Address: “;
my $IP = ;
chomp $IP;
print “Checking their IP\n”;
my $p = Net::Ping->new(“icmp”);
print “$IP is alive.\n” if $p->ping($IP);
print “$IP is as dead as a Dodo.\n” unless $p->ping($IP);
# 1 will get the external IP from
if ($answer eq “1”) {
my $html;
$html = get( ‘’ );
chomp $html;
print “Checking your IP\n”;
# Print the result from the html file
$html =~ s/.*ddress: //;
$html =~ s/<\/body.*//;
print “$html\n”;

# Remove the html tags from the message and set the resulting IP as $address
my $address = $html;
chomp $address;
$address =~ s/.*ddress: //;
$address =~ s/<\/body.*//;

# Print a ping message
print (“Pinging $address\n”);

# Ping the IP address and report if it is up
my $p = Net::Ping->new(“icmp”);
print “$address is alive.\n” if $p->ping($address);
print “$address is as dead as a Dodo.\n” unless $p->ping($address);

As I said, quite basic, and you could just manually ping an IP from the terminal, no need for a script. However, as with most scripts and one-liners, it’s about finding out how to perform certain actions which can be applied to other uses.


Simple Bash Backup Script

I often play around with little Bash scripts and Perl One-Liners in my quest to learn more. This particular script backs up specific data that I need when I reinstall an (Debian) OS.

I’ve got various versions and this is just a base (which you can add-to and play with). As always, with any code, especially Bash, there are a whole heap of ways to write backup scripts, both long and short, but this script is only intended to show newer users some basic commands, and to act as a template for further investigation.

#! /bin/bash
echo Backing up your data…
echo Backup started `date` >> ~/backuplog
cd /storage
mkdir -p backups/`date +%Y%m%d`
mkdir -p backups/tmpdata/important/
sudo cp /etc/host* backups/tmpdata/important/
sudo cp /etc/X11/xorg.conf backups/tmpdata/important/
sudo cp /etc/network/interfaces backups/tmpdata/important/
sudo rm -rf /home/rich/.local/share/Trash/files/*
sudo cp -a /home/rich backups/tmpdata/
cd backups/tmpdata
tar -czf /storage/backups/`date +%Y%m%d`/bkp.tar.gz *
cd ..
sudo rm -rf tmpdata
echo Backup Finished `date` >> ~/backuplog
echo All your data successfully backed up!

Spain rejects Sinde Law

It looks like Wikileaks is making people think for once

Spain last night killed a controversial anti-P2P bill that would have made it easier to shut down websites that link to infringing content. The move was a blow to the ruling Socialist government, but it may be of even bigger concern to the US, which pushed, threatened, and cajoled Spain to clamp down on downloading. And Wikileaks can take a share of the credit for the defeat.

Known as the “Sinde law” (ley Sinde) after Spain’s current culture minister, the bill was actually an amendment to a much broader economic rescue package known as the Sustainable Economy Bill. The Sinde law would have set up a new government committee that could draw up lists of sites which largely link to infringing content. These sites would then go to a Madrid court, which would have four days to rule on whether they should be fully or partially blocked.

Spain has become notorious among rightsholders for its levels of online piracy. International music trade group IFPI said earlier this year that Spain “has one of the highest rates of illegal file-sharing in Europe” and that “sales by local artists in the top 50 have fallen by an estimated 65 percent between 2004 and 2009.”

That’s of real concern to local Spanish artists, but it’s also a big deal to Hollywood and the US music industry, which together supply plenty of the pirated fare. They’ve leaned on the US government, which has in turn leaned on Spain—and hard.

I’ve got a little list

Thanks to Wikileaks, we now have access to some of the cables sent from the US Embassy in Spain, and they show just how the US gets things done in other countries. Spanish daily El Pais reported on these cables at length and made them front-page news in Spain; for English-speaking readers, the Electronic Frontier Foundation has a helpful summary.


Debian 6.0 Squeeze to be released with complete free Linux Kernel

Debian finally provides a Stallman/Fsf friendly kernel

The Debian project has been working in removing non-free firmware from the Linux kernel shipped with Debian for the past two release cycles. At the time of the releases of Debian 4.0 Etch and 5.0Lenny, however, it was not yet possible to ship Linux kernels stripped of all non-free firmware bits. Back then we had to acknowledge that freedom issues concerning Linux firmware were not completelysorted out.

We have nonetheless kept on working on splitting away non-free bits from the Linux kernel, thanks to the work of the Debian Kernel team and various Linux upstream developers. We are proud to announce that, to the best of our knowledge, all issues are solved and that we will be able to deliver a Linux kernel which is completely Free, according to the Debian Free Software Guidelines (DFSG), with Debian Squeeze. We hereby reaffirm Free Software as one of our priorities, as documented in the Debian Social Contract.

In accordance with the Debian Social Contract, we acknowledge that some users require the use of works that do not conform to the DFSG and that those works might include non-free firmware bits. For the time being, we have added to the non-free area of our archives alternative installation images and additional packages for Debian Squeeze, that include non-free firmware bits needed to enable specific pieces of hardware. They are not part of Debian, they should be looked for explicitly by interested users, and we cannot support them to the same extent of Free firmware as we do not have access to the corresponding source code. We encourage hardware manufacturers to release only DFSG-free firmware and we cannot accept other kind of firmware as part of Debian.


Tribler decentralized P2P Torrent App on Debian Squeeze

Tribler means no more central servers or tracker downtime. You ARE the Network.

From: TorrentFreak

BitTorrent is a great technology to share files both quickly and efficiently, but like all other P2P-technologies it has an Achilles’ heel. The download process relies in part on central servers that can crash or go offline for a variety of reasons. To address this vulnerability the first truly decentralized BitTorrent/P2P client has been developed, meaning that no central trackers, or even BitTorrent search engines are required to download movies, software and music.

BitTorrent is branded as a peer-to-peer technology, but despite this label the downloading process still relies heavily on central servers. In the first place there are the BitTorrent search engines and indexes such as The Pirate Bay and isoHunt. These are needed to search for content and to grab the .torrent file one needs to download a file.

Tribler install on Debian Squeeze
I decided to give it a go on Debian Squeeze. Even though they say they are still working on the Linux version, there are some Ubuntu related .deb files available for download.

So I downloaded this file from

A “dpkg -i tribler_5.2.1-1ubuntu1_all.deb” threw up dependency errors, so i issued an “apt-get -f install” to install any dependencies.

Vlc and Python-vlc
Tribler relies on VLC media player to play music and video, and as such also needs the VLC python bindings.
Unfortunately an “apt-cache search” showed me that there is no python-vlc package in the Debian Squeeze repos, so I searched Google and found an Ubuntu version here:
I downloaded the latest i386 version (HERE) and installed it via dpkg and then reinstalled Tribler. Everything installed nicely and I now have it up and running on my Debian Squeeze laptop.

Screenie of Trible on Debian Squeeze with OpenBox desktop

E.E.U.U deciden los derechos de autor de España – Wikileaks

¿Quien manda a España?
El Congreso de España está a punto de votar un nuevo Derecho de Autor/ Derecho de Internet muy dura. Es un secreto abierto, dice que la ley fue redactada esencialmente por los grupos de la industria Americana de trabajo con el representante comercial de EE.UU. Es decir, estan decidiendo vuestros derechos de internet, y que puedes y no puedes acceder.

El Gobierno de España decide nuestros derechos, o los E.E.U.U
Sin embargo, se pone más interesante: 115 de los cables de Wikileaks interceptado por la embajada de EE.UU. en Madrid estaban etiquetados con “KIPR” – es decir, en relación a la “propiedad intelectual” La gran pregunta ha sido: a El País, el periódico español que tiene el tesoro completo de cables de Wikileaks, los pongan en libertad a tiempo para afectar a la votación sobre la nueva ley?

Pues los E.E.U.U
Bueno, ahora que he empezado. Los primeros 35 de los 115 cables han sido liberados, y confirman la sospecha generalizada: el gobierno español y el partido de la oposición se llevó alrededor de la nariz por los representantes de EE.UU. que son la verdadera autoridad legislativa en España.

Un estado títere de EE.UU
Así que aquí está la nueva pregunta: cuando los españoles los votos del Congreso en la ley de copyright de Estados Unidos este mes, van a votar por su soberanía, o actuar como un estado títere de EE.UU.?

La prioridad que los estadounidenses otorgan a la cuestión se manifiesta en el nivel de los interlocutores elegidos. La vicepresidenta María Teresa Fernández de la Vega es uno de los primeros objetivos. Un agregado de la Embajada habla del tema con ella el 22 de febrero de 2005. El cable 27536, elaborado por el agregado al día siguiente de la conversación con De la Vega, se cierra así: “Dada la cantidad de estrellas de la industria del entretenimiento con una abierta preferencia por el Gobierno socialista (es significativo, por ejemplo, que Zapatero acudiera al equivalente español de los Oscar), es posible que este Gobierno sea especialmente sensible a hacer algo en este sector. Necesitaremos un año o así para ver si esta sensibilidad se traduce en resultados”.
El 10 de noviembre de 2005, el embajador se entrevista con la ministra de Cultura, Carmen Calvo: en el cable 45583, el propio embajador concluye que en el Gobierno español hay buenas intenciones, pero no hay resultados.

La tónica se mantiene. La potente Motion Pictures Association, que agrupa a las majors de Hollywood, presiona desde EE UU. La industria local española también se queja de la permisividad con las descargas, sobre todo la musical. En 2007 se produce el punto de inflexión: el 28 de diciembre, la delegación estadounidense en Madrid emite un cable (135868) que contiene un minucioso plan. Asunto: estrategia para los derechos de propiedad intelectual en España. El despacho despliega un detallado plan a corto, medio y largo plazo plagado de citas con responsables políticos, con mandos intermedios de los ministerios de Cultura e Industria, encuentros con las operadoras de telecomunicaciones, visitas a España de expertos norteamericanos… y anticipa, ya, la medida que hay que tomar a medio plazo: colocar a España en la lista negra.

virt-manager ERROR:root:Unable to initialize GTK: could not open display

I recently installed Kvm on my Debian server to have a play with Qemu Virtual Machines. We have this set up at work so i’m pretty familiar with the system.

However, after installing kvm, qemu, vnc4server and vnc4viewer to access my server, when I tried to run virt-manager one of two things happened.

1. As a normal user I had no privileges to create or manage VM’s
2. As root or sudo user virt-manager wouldn’t even launch from the terminal, just gave me a whole string of Gtk error messages.

virt-manager ERROR:root:Unable to initialize GTK: could not open display

So, methinks, A: I need root/sudo privileges, BUT! you NEVER, EVER run graphical apps as root, it’s a no-no.

That’s where I found the solution. To run graphical apps as root/sudo you use GKSU not SU


sudo apt-get install gksu

sudo vim /usr/bin/virt-manager

Then in between exec and python, just add a gksudo like this:


exec gksudo python “/usr/share/virt-manager/” “$@”

Now when I run virt-manager as a normal user, everything is fine.