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

  • Motion Sensor

    Inotify lets applications subscribe to change notifications in the filesystem. Mike Schilli uses the cross-platform fsnotify library to instruct a Go program to detect what's happening.

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

  • Maltrail

    Maltrail is a lightweight analysis tool that examines network traffic and raises the alarm if it detects suspicious access or dubious name resolution.

comments powered by Disqus