Detecting system changes with Dnotify

FILE RESCUE

Article from Issue 63/2006
Author(s):

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

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
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: Lyrical Logfiles

    Instead of just monitoring incoming requests in your web server's logfile, a sound server makes them audible and lets you listen to the tune of users surfing the site.

  • Monitoring with incron

    The incron utility provides an easy way to initiate commands and scripts triggered by filesystem events.

  • 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.

comments powered by Disqus

Direct Download

Read full article as PDF:

Perl_noworries.pdf (248.09 kB)

News