Shell scripting

How to prevent the Windows screensaver from locking your screen

Sometimes system administrators set a shorter (than agreeable) idle timeout for your screensaver (eg. via group policy) and do not grant you the rights to change it. Eg. some people think that 10 minutes of "inactivity" (ie. no mouse or keypress) must mean that you've left your computer and it must be locked to prevent malicious access. Obviously I'm not such an administrator and I think that enforcing this kind of security assuming everybody is a moron and incapable of locking their workstation if going away is a bad thing (locking every workstation after 10m of inactivity will not improve the company security ... in fact I believe that it'll just make everybody angry and it'll drive people to try to circumvent the limitation ... sometimes opening a lot larger security whole in the process).

How to copy a file and print the progress

There can be a number of reasons for starting a file copy from the command line (eg. you're on a headless server Smiling ). Copying large files (eg. virtual machine images) can take some time and without feedback you can just guess how much is still left. The dd command can print the desired progress, but it takes more than just a command line option to get there. Here's an example to make it print the progress every 10 seconds:
dd if=input_file of=output_file bs=1M & pid=$! && while sleep 10 && kill -USR1 $pid 2> /dev/null; do :; done

logger - a shell command interface to the syslog system log module

Logger makes entries in the system log. It provides a shell command interface to the syslog system log module.

Mozilla (Firefox + Thunderbird) profile cleaner for linux

It happens occasionally that after a crash (Firefox/Thunderbird or the PC itself) starting up Firefox (or Thunderbird) you experience weird behaviour. Eg. it tells you that the app is already running or it starts, but bookmarks are not available, etc. Cleaning your profile can be easily done manually by removing a couple of files in your Firefox/TB profile, but average users are not familiar with contents of these profile folders. To help them I've written a small app (shell script using Zenity to provide a GUI) that you can put in your Gnome/KDE/etc. menu so all your users can easily access it. Of course, you're free to customize the script anyway you like (eg. take out a few questions to make it even more automatic). I've tested the script in Ubuntu 9.10 (Firefox 3.5.9 and Thunderbird 2.0.0.24).

Various set operations (union, intersection, difference) on two text files

I didn't know about the comm command. It's the ideal solution to generate the "set symmetric difference" of two text files.

Regular calls to Drupal cron.php scripts on a server with a number of Drupal sites

Calling the cron.php of a Drupal site is fairly easy. You just have to put something similiar into your server's /etc/crontab:
0 * * * * www-data test -x /usr/bin/wget && /usr/bin/wget --bind-address 127.0.0.1 -t 1 "http://example.com/cron.php"
Or you can place this wget call in a file in /etc/cron.hourly.

However on a server with quite some Drupal sites (and possibly a number of virtualhosts) the maintenance of these cron.php calls in your crontab becomes very annoying (and it is prone to errors). On a busy development server Drupal sites come and go every day. So why not do these calls automatically? The attached script does just that. Smiling

Running a script on logout from Gnome

There's a nice Python script for the job at linuxquestions.org written by Seamus Phelan. I've tested it, found a few problems and fixed them.

Gtkdialog - complex GUI for scripts

"Gtkdialog is a small utility for fast and easy GUI building. It can be used to create dialog boxes for almost any interpreted and compiled programs which is a very attractive feature since the developer does not have to learn various GUI languages for the miscellaneous programming languages."

Gtkdialog is not just a simple xdialog replacement like Zenity. It allows creation of complex GUI with event-driven controlling logic. The GUI layout is described in XML files. Quite fancy. Smiling

Zenity - Gtk+ dialogs for shell scripts

Just found out about this: "Zenity is a tool that allows you to display Gtk+ dialog boxes from the command line and through shell scripts. It is similar to gdialog, but is intended to be saner. It comes from the same family as dialog, Xdialog, and cdialog, but it surpasses those projects by having a cooler name." Seems to be pretty useful. The original project homepage is at GNOME Live.

Automatized online backup of MySQL databases using LVM snapshots

This is again a script that people could write easily if they understood some shell scripting, but it is quite well implemented with logging and all and maybe spares a couple of minutes/hours of your time. Smiling

You should use it with crontab on a daily basis. For details take a look at the desc. of the MySQL backup script.

Syndicate content