Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Automating program use logging on Win32

by c4onastick (Friar)
on Mar 17, 2008 at 23:47 UTC ( #674676=perlquestion: print w/replies, xml ) Need Help??
c4onastick has asked for the wisdom of the Perl Monks concerning the following question:

Greetings fellow monks!

Today was a most joyous occasion for me, I was actually asked to implement some sort of digital logging mechanism to track instrument usage! (That may not sound like much, but technology is terribly underutilized at this company.) I'm just a scientist with a programming hobby so this means that all the time I've spent meditating here at the monastery has helped me get to a place where I'm actually asked to tackle these sorts of problems so I humbly thank all of you for your guidance over these years. It also means that the seed of change has been planted and they are starting to realize that a computer can be more than just a giant typewriter!

Unfortunately, this wont be easy. I've tried to automate other parts of the software in question before with little success (Collecting data from a program that doesn't make it easy). What would be ideal would be to record the start time and end time of the instrument's operation and maybe a few other details (who's running it, what study, etc.). My initial thought was to write a little bat script to call a little perl program to log the time, user, study etc. then call the instrument's software. (Maybe even bracket that with another script to record the time the software is closed, assuming it's closed when it's done being used.)

The downside of that is I'd have to install and maintain perl on quite a few machines (not terrible, I agree, but laziness is a virtue). I do, however, have access to all the data directories over the network. So, what I'm wondering is if there is another, less obtrusive way to log usage, say perhaps by monitoring the data directory for new files and logging the creation and last modification time? Has anyone run into similar problems on Win32? Any thoughts on alternate ways to tackle this problem?

Thanks in advance!

  • Comment on Automating program use logging on Win32

Replies are listed 'Best First'.
Re: Automating program use logging on Win32
by igelkott (Priest) on Mar 18, 2008 at 01:16 UTC

    Use Win32::ChangeNotify to notify your script of file events. Since you can monitor from a central location, this may be all you need.

    If you find that you need to monitor from many computers, see pp for a solution which doesn't require a Perl installation on each.

Re: Automating program use logging on Win32
by chaos_cat (Scribe) on Mar 18, 2008 at 12:47 UTC

    There are a few things you could do here to make this easier. For one, rather than make a batch file+script for each instrument's software, you could just make a single wrapper which would take the instrument as a parameter, do the logging and then look up the correct software to call (from a hash, for example, or a database if you have already invested in that infrastructure).

    You could also write plain batch file wrappers (or again, a single wrapper) which dump the user/study/instrument/start-time to a single log and then build a perl script to parse through that file. To get end times, I'd just have the wrapper batch file make a log entry before and after the instrument code runs. You could even ftp these logs to a central server where your perl script could do the parsing, meaning you'd only have to maintain one instance of perl, if that's an issue.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://674676]
Approved by ww
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2018-03-22 03:17 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (272 votes). Check out past polls.