Archive for December, 2006

send files through email from the command line

Wednesday, December 20th, 2006

Every now and then I need to send by email some file to a friend or coworker or even myself. I have found that the easiest way to do this is just having a shell script that do the hard work for you.

After some research I found a set of scripts that actually do what I want (credit goes to Heiner Steven). The bad news is that this is not a full-bash solution. The scripts use the metasend command to send files as MIME atachments.

(more…)

runningserver: hello? anybody out there?

Wednesday, December 20th, 2006

I have created a small ruby script to check if there are running servers on a given port number. The script is able to check a list of hosts and will output an informational message on the port status for each host.

Let’s begin with the script. Then we can talk about the work it does.
(more…)

matar: bloodlust

Friday, December 15th, 2006

Here is a tiny script that can be usefull to terminate (kill -9) all the programs which contain a certain string (i.e.: kill all the running copies of ping).

#!/bin/bash

for foo in `ps aux | grep $1 | awk '{print $2}'`;  do kill -9 $foo; done

Just run: matar <program name> and that’s it. They are all gone.

icmp timestamps

Thursday, December 14th, 2006

The Timestamp is an ICMP (rfc792) message which is used for time synchronization. The Timestamp Reply message consists of the originating timestamp sent by the sender of the Timestamp as well as a receive timestamp and a transmit timestamp.

If your machine answers ICMP Timestamp messages an attacker can learn the date which is set on your machine. This may help him to defeat all your time based authentication protocols.

(more…)

new category: ruby

Thursday, December 14th, 2006

Ruby language logo

Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.

Or that is what it is said in the official web site :) Do not forget to check API and docs. It is worth having a look, because the learning curve is really fast!

replace spaces in filename

Thursday, December 14th, 2006

Just a quick tip!

You have to use the bash function ${foo//string1/string2}. Check the Advanced Bash-Scripting Guide for a complete list of string manipulating functions.

for foo in *; do mv "$foo" ${foo// /_}; done

kde desktop background auto change

Thursday, December 14th, 2006

Much in the way we did with xfce here is the way to implement de auto change feature in KDE.

This is an easy one. Although you can perform background auto change from KDE control center, it may be usefull to have a script to do the task. You can use this script to create a link in your desktop to change the background image when you want.

The KDE applications can be controlled by scripts via the DCOP mechanism. From the Wikipedia:

DCOP, which stands for Desktop COmmunication Protocol, is a light-weight interprocess and software componentry communication system. The main point of this system is to allow applications to interoperate, and to share complex tasks. Essentially, DCOP is a ‘remote control’ system, which allows an application or a script to enlist the help of other applications. It is built on top of the X Window System’s Inter-Client Exchange protocol.

(more…)