Admin @ 01 May 2009, “No Comments”

Recently I’ve noticed there are lots of spam with just text and URL. This spam passed through spamassassin’s checks all the time. Good news, there are some fabulous URL block lists. I’ve used two of them:

SURBL and URIBL
These two checks url block lists, mentioned in message body.

Admin @ 02 December 2008, “No Comments”

Just a link to remember. If you want to backup your entire partition using dd:

Creating a hard drive backup directly to another hard drive

Also, very useful boot cd with live linux and utility partimage: System rescue CD

Admin @ 11 February 2008, “No Comments”

I have data recieved from ftp, which is encoded using GnuPG software.

To get files nightly, I used cron task scheduler. But there were problem when decoding gpg files (when ran shell script, everything went ok, but when cron initialised, no decryption were done).
This is a shell script:

gpgdir=/path/to/recieved/gpg/files/

for i in `find $gpgdir -name ‘*.gpg’  -type f -maxdepth 1` ; do
echo ‘thepassword’ | /usr&/bin&/gpg  passphrase-fd 0 -o ${i%.*} -d $i
done
 

As you can see, script finds all *.gpg files in given directory, then passes file by file to gpg to decode files.
But it does not work when executed with cron.

After some debugging, found such error:

gpg: fatal: cannot open /dev/tty

So, gpg tries to open tty, but in cron enviroment there is no access to tty. So found out switch to gpg no-tty.

This is the final, working excerpt from my script:

gpgdir=/path/to/recieved/gpg/files/

for i in `find $gpgdir -name ‘*.gpg’  -type f -maxdepth 1` ; do
echo ‘thepassword’ | /usr/bin/gpg  no-tty  passphrase-fd 0 -o ${i%.*} -d $i
done
 

P.S. Echoeing password through pipe to give it as parameter to gpg is not secure, if your server is accesed by other users. At good timing, user can get your password. As my server accessed only in trusted LAN, and no other users use shell, I’ve made that method.

Admin @ 11 December 2007, “No Comments”

If you are using linux crontab to automate some processes, allways use full path to scripts or other executable files.

Recently, I was writing one bash script, which uses munpackutility. Tested it – worked with no problems. After adding script to crontab, to do this routine daily, I’ve noticed, that something is wrong.

Problem was, that munpack was in /usr/local/bin/bin/munpack directory, and there was created symlink /usr/local/bin/munpack.

So, crontab didn’t follow symlink.

Admin @ 01 October 2007, “No Comments”

Recently I was writing Bash shell script, which moves files and directories from one server to other. As files and folders are created by end users, there are problems about file names.

Users create folders with spaces e.g. very important and Bash script interprets it as two separate folders: very and important when my script finds all folders and starts to move them, I get error on folders with spaces. This is the command:

mv -fv `find /mnt/volume/tomove -mtime +14` /path/tomovewhere

This piece of code moves files and folders older than 14 days from /mnt/volume/tomove to /path/tomovewhere

So, if there is folder /mnt/volume/tomove/very important
Bash tries to move /mnt/volume/tomove/very and important

To interpret directories as one command you will need to add this variable to your script:

IFS=$\n

$IFS is internal field separator, this variable determines how Bash recognizes fields, or word boundaries, when it interprets character strings.
You can find more info with samples here:
http://tldp.org/LDP/abs/html/internalvariables.html