Detecting system changes with Dnotify


Article from Issue 63/2006

We'll show you how you can avoid the tragedy of lost files with a transparent, Perl-based version control system.

During early phases of a project, developers tend to experiment with various options, and sometimes it is too early to save prototypes in the version control system. If you haven’t set up a repository, or if you haven’t been able to agree on its structure, you might find yourself working without a safety net. In this case, good code might fall victim to an over-zealous rm * or your editor’s delete command. This month’s Perl script, noworries, can give you automatic version control. Whenever you save a file with your editor, and whenever you use the shell to manipulate files using commands like rm or mv, a daemon hidden in the background receives a message. When it does, it picks up the new or modified file, and uses RCS to version the file. All of this is transparent to the user. Figure 1 shows a user creating and then deleting a new file in the Shell. Without some Perl wizardry, the file, myfile would have been gone for good, but calling noworries -l myfile tells us that the versioner created a backup copy just 17 seconds earlier. noworries -r 1.1 myfile retrieves the file and writes its content to STDOUT.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Realbasic

    Realbasic provides an easy solution for converting Visual Basic programs to Linux.

  • Revision Control System

    The Revision Control System (RCS) provides simple, reliable version control without the complexity of bigger systems like Subversion or CVS.

  • Perl: Network Monitoring

    To discover possibly undesirable arrivals and departures on their networks, a Perl daemon periodically stores the data from Nmap scans and passes them on to Nagios via a built-in web interface.

  • Offline FS

    Tired of copying and recopying files from your laptop to the office file server? Maybe you need an automated offline filesystem, such as OFS.

  • Twisted

    The Twisted framework makes it so easy to create network-aware applications in Python. Twisted speaks all the major Internet protocols, from mail through chat, and it can handle encryption. We’ll show you how to set up a personal web server with Twisted.

comments powered by Disqus

Direct Download

Read full article as PDF:

Perl_noworries.pdf (248.09 kB)