Ubuntu, torrents and anti-virus trick

There are probably a lot of ways to scan downloaded files after completion in Ubuntu.
I run an old P4 download server with Ubuntu, and I want to scan my downloads for virusses before I use them on a Windows machine.
I installed Avast, which has command line access to the scanner.
I use Deluge (for its great WebUi) and for some reason the “execute on completion” plugin did not work.

In my case, Deluge moves completed downloads to “/storage”

Here’s my solution: I installed dnotify and use it to trigger Avast.

dnotify -C /storage -r -e avast -p=1 /storage

…will trigger a scan of the folder, right after a file has been created.
-C is to trigger an event on file creation
-r is for recursive monitoring
-e is the command that needs to be executed
“avast -p=1 /storage” is to run an Avast virus scan.
Warning: the “-p=1” option deletes infected files without warning.

You can replace the directory “/storage” with your own.

I know, the method is rude – but it works like a charm.

Ubuntu, Fedora and Linux Mint

One day while testing the beta of Windows7 a message appeared: “This beta will expire in 6 hours”, or something similar. I had been thinking about making the switch to Linux, in this case Bill left me no choice. I downloaded the latest Ubuntu version, formatted my hard disk and installed the “Jackalope”.

I had tried Ubuntu a couple of years ago, and it took me two weeks to figure out how to install my video card drivers. Irritated I gave up backup then, because productivity was down to zero while struggling with an unknown OS. Luckily most Linux distro’s have come a long way since, including Ubuntu. The installation went smoothly, a pop-up appeared telling me that “proprietary drivers were available”. Even more, it told me that these drivers weren’t open source, and I would be depending on the manufacturer for updates, so the Linux community marked them as a “security risk”.
They worked fine nevertheless. I was relieved that most of my hardware worked “out of the box” with the new Ubuntu. Only my web cam didn’t, but I never used it anyway.

Since Ubuntu I have tried a couple of Linux distro’s on several computers in my home. Now I’m not a real expert, I only have a couple of months experience with Linux, but here are my findings:

Ubuntu logo
Ubuntu 9.04 “Jaunty Jackalope”
Very easy to install, graphical installer (but that goes for the other distro’s mentioned here as well). Most hardware works out of the box. Missing codecs bring up a search function, and most can be installed effortless. Very calming interface & colors (when I went back to XP for an hour, I got real nervous and agitated). Great desktop effects with Compiz Fusion, including Desktop Cube.
All in all a very stable OS, great looking, needs a little tweaking and post-installing. Why is my wireless re-enabled after each restart? I have to switch it after off every boot!

Fedora 11 logo
Fedora 11
Wins hands down on speed, absolutely the fastest distro I have ever seen. Brilliant. Very clean look and feel, feels like a computer hardware upgrade. Only basic required software is pre-installed. Codecs (even for mp3?) must be installed manually. Flash, Silverlight, xvid, divx… good luck with these (for experienced users they will not be a problem). A great light-weight operating system, but it needed the most post-install time of all distro’s I tried. Runs great on our budget Acer lap-top, except Firefox hangs on certain javascripts (anybody?)

Linux Mint logo
Linux Mint 7 “Gloria”
Linux Mint is based on Ubuntu, and it looks like a bunch of Ubuntu users got together and decided what to remove and add. The results are fantastic: a new menu with favorites, a better software installer with ratings and reviews, full-screen pictures and so on. All codecs are pre-installed! Flash, Silverlight, mp3, video codecs, plugins, addons, you name it. This saves me an hour or two after installing. Linux Mint has a color scheme that makes you question the Ubuntu-brown. There are many other improvements and changes, all in all I favor Mint over Ubuntu.
After installing this OS, it feels like you don’t have to do anything yourself.

Xfce logo
Linux Mint Xfce Edition
Now this is a version that uses the Xfce Desktop Environment (instead of KDE or GNOME). I don’t think there’s anything wrong with KDE and GNOME, but when I tasted the more lightweight Xcfe desktop, I was sold instantly. To this day this is my favorite distro: a perfect balance between usability and speed. Faster than KDE, not too bulky, but also not stripped down like Fedora (Fedora it isn’t called “Core” for no reason). I just love its simplicity and stabilty.

Now some Linux pro could probably prove me wrong on all points, or show me a distro that’s even better. No really: please do!
But that depends on what you are looking for: for me the best mix between an easy install, a light-weight desktop and a feature-rich OS has been Linux Mint Xfce. Maybe when I’m better used to Linux I will run that mighty fast Fedora again.

Time-lapse script

I have been capturing video from the sky for years. When I used to run Windows, I wrote my own software for making time-lapse movies.
After I switched to Linux (first Ubuntu 9.04, now Linux Mint 7) I had to “reinvent” time-lapse capturing.
Then I came across a nice script that I could modify. Run this script in a terminal:


echo "Video device?"
read devnum
echo "Video input?"
read inpt
echo "Frame interval seconds?"
read intv

[ -p my.fifo ] && rm my.fifo
mkfifo my.fifo

mplayer -slave -quiet -input file=my.fifo -vf screenshot,scale=768:576 -tv driver=v4l2:input=$inpt:fps=1:norm=pal:width=768:height=576:\
device=/dev/video$devnum tv:// &
while true
echo "screenshot 0" >my.fifo
sleep $intv
name=`ls -tr shot*.png | tail -n1`
mv $name img/timelapse-`date +%y%m%d_%H%M%S`.png

This script asks for your video device ($devnum), the video input line ($inpt) and a frame interval in seconds ($intv).
It opens mplayer to display the video live, and starts taking .png screenshots in directory “/img” (create first!)
To close, simply click away the mplayer or the terminal.

Now we have to convert the images into a movie:


echo "Movie width?"
read pix_x
echo "Movie height?"
read pix_y
echo "File type? png bmp jpg"
read filetype
echo "Delete stills when done? (y/n)"
read del_permis

if [ $filetype = 'bmp' ]
echo "Converting from " $filetype "to png..."
mogrify -format png $filetype/*.$filetype
echo "Moving png..."
rm -r $filetype/*.$filetype
echo "Deleting " $filetype "..."
mv $filetype/*.png img
echo "Done."


FNAME=tl-`date +%y%m%d_%H%M`.avi
cd img/
mencoder mf://*.$filetype -mf w=$pix_x:h=$pix_y:fps=25:type=png -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:vbitrate=5000 -oac copy -o $FNAME
mv *.avi ../avi
if [ $del_permis = 'y' ] || [ $del_permis = 'Y' ]
rm -rf *.$filetype
echo Stills deleted
echo Stills kept
echo "Finished, press any key to exit"
read anykey

This script asks for a file type (png/bmp) because sometimes I need to convert bitmaps into a movie.
Default is “png” from the “img” directory, but I can choose “bmp” from the “bmp” directory.
Then it runs mencoder to create the movie, and optionally deletes the stills after completion.
I created two links in my main menu (“timelapse” and “makemovie”) and I was ready to capture another day…