directory_monitor.pl – Monitor directory for file changes

Posted on .

I wrote this perl script to monitor a directory for changes in files such as ,

  • Created
  • Deleted
  • Modified

A directory is given on the command-line and the script continuously checks for changes until it is halted (ctrl+c).

Example output,

$ ./directory_monitor.pl /tmp/

Monitoring directory: /tmp/
(ctrl+c to halt)

20080209.145857 : test.txt Created. [0b]
20080209.145904 : test.txt Size changed to 375b (up 375b)

I was having issues with MythTV prematurely deleting recorded shows, and this script proved its worth in determining when they were deleted.

Download
  directory_monitor.pl (4.6 KiB, 5,843 hits)

pingstatus.pl — Check for server downtime.


Wanting to continuously check if a server is losing connectivity, I quickly put togethor a small perl script to do the job.

Open the file and edit the variables to determine debug status, email details, server ip etc.

By default it sends a ping every second. If this test fails 5 times in a row, a report is sent via mail.

Disable debug for it to run silently in the background.

pingstatuspl-check-for-server-downtime-image1

Download
  pingstatus.pl (2.4 KiB, 2,674 hits)

exifsort.pl – Sort digital images by EXIF date.


I use 2 digital cameras, and my phone, to take pictures nearly every day. I came accross a perl script written by Lars Strand. This copied photos from CAM0001.JPG to a date formatted file such as 20070113.0900.JPG.

I decided to take this as a base, and change it into something that suited my own needs.

The script will take directories on the command-line and copy any pictures found to a target directory set within the script. It then creates a file and directory structure based on the EXIF time/date found in the JPEG.

For example

/source/CAM0001.JPG

now becomes

/target/2007/11.nov/20070113.0900.jpg

making the files easy to find and splitting them into months.

The script produces an output such as,

ExifSort v1.0 - http://www.nooblet.org/exifsort/

o Processing folder, /mnt/storage/Photos/100DSCIM/
o Processing folder, /mnt/storage/Photos/100CASIO/
CIMG0553.JPG -> 20071111_145714.jpg
CIMG0554.JPG -> 20071111_153500.jpg
CIMG0555.JPG -> 20071111_153529.jpg
CIMG0556.JPG -> 20071111_153614.jpg
CIMG0557.JPG -> 20071111_155707.jpg
CIMG0564.JPG -> 20071111_181839.jpg
CIMG0567.JPG -> 20071111_182038.jpg
CIMG0569.JPG -> 20071111_182659.jpg
CIMG0574.JPG -> 20071111_215006.jpg
CIMG0575.JPG -> 20071112_120508.jpg
CIMG0580.JPG -> 20071112_120723.jpg
CIMG0582.JPG -> 20071112_182803.jpg
o Processing complete.
12 files copied.
- 101 files the same.

The script checks modified dates and file sizes, and will compare the md5 checksum if it still isn’t sure, to know if it has already copied an existing file.

The photos folder in my family photo gallery is a direct result of this exif sorting script.

Requirements:

Download
  exifsort.pl (5.2 KiB, 3,897 hits)

Administrative Rights on Startup/Logon in Vista

Posted on .

The new User Access Control (UAC) in Windows Vista is an interesting feature. Whilst it keeps me well informed as to the security status of each program I run, it can become a hinderence to productivity.

One such issue I am having is loading programs at startup that require Administrative Rights. Currently Vista will not allow an elevated program to run on startup via the usual methods. But there is a work around using the Task Scheduler as I found on the Lavalys forum.

In order to create a task which runs with admin rights, you need to be logged in as an Administrator. These steps will not allow you to run an elevated program if you don’t already have the rights to do so.

  1. Open Task Scheduler by pressing the Start button and typing task scheduler and pressing enter.

    administrative-rights-on-startuplogon-in-vista-step1

  2. Create a new Task through the Action menu.

    administrative-rights-on-startuplogon-in-vista-step2

  3. Choose a name for the Task, and make sure Run with highest priveleges is ticked.

    administrative-rights-on-startuplogon-in-vista-step3

  4. Choose Triggers from the tabs at the top, and click New.

    administrative-rights-on-startuplogon-in-vista-step4

  5. Choose At log on from the Begin a task option.

    administrative-rights-on-startuplogon-in-vista-step5

  6. Either pick a user, or choose “Any user” if you want this to run on log on for everyone. Make sure everything else is not ticked except for “Enabled”. Click OK.

    administrative-rights-on-startuplogon-in-vista-step6
    administrative-rights-on-startuplogon-in-vista-step6b

  7. Choose Actions from the tabs at the top, and click New.

    administrative-rights-on-startuplogon-in-vista-step7

  8. Click the Browse button and find the program you want to load at logon/startup. In the Lavalys example it would be the Everest executable. Click OK.

    administrative-rights-on-startuplogon-in-vista-step8

  9. Click the Settings tab and make sure the only checkbox ticked is Allow task to be run on demand.

    administrative-rights-on-startuplogon-in-vista-step8b

  10. Click OK again to save your new task. Check it has been created properly by clicking on Task Scheduler Library on the left pane of the Task Scheduler. Thats it, you’re done. Reboot and see if it works!

    administrative-rights-on-startuplogon-in-vista-step9