Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: LSOF Perl Implementation

by biosysadmin (Deacon)
on Jun 06, 2005 at 20:22 UTC ( [id://464067]=note: print w/replies, xml ) Need Help??


in reply to LSOF Perl Implementation

I often find myself saying similar things in a quest to make my scripts as general and as portable as possible. If there were a Unix::lsof CPAN package available, I think you would be remiss in not using it. However, since there does not appear to be one, you have two options:
  • Write your own package. This isn't really as difficult as you might think, and you could initially make it work on Linux (I'm assuming that you're using Linux) and port it to other operating systems later. For example, Solaris and FreeBSD probably wouldn't be difficult at all.
  • Just use the pipe idea shown above. It has some very important strengths: it's simple, it works, and it gets the job down.

In a perfect world we'd always use a well-tested and highly portable CPAN module for things like this, and all of our Perl scripts would be portable to a wide variety of operating systems. However, it's important to sometimes forgo idealism in order to get the job done. Cheers. :)

Replies are listed 'Best First'.
Re^2: LSOF Perl Implementation
by hubb0r (Pilgrim) on Jun 06, 2005 at 20:50 UTC
    At the moment, the way I am doing it is with the pipe. The reason that I was looking for a more pure-perl implementation or a wrapped c-code implementation was that this is running in a script that sometimes runs MANY times (often simultaneously) (it's a ftp-server postprocessor). The need for the lsof call is that there is some apparent corruption happening on certain files (and they are all rijndael encrypted, hence 1 1 byte corruption is VERY bad!!) and it appears to me that the FTP server is holding open a file during a rename and I am processing the file prior to it flushing the buffer or something.

    Tha bug is very frustrating, and also quite difficult to track down. It's a complex system involving PocketPC devices, a linux server running proftpd, plus lots of backend post-processing of the files created by the pocketpc devices...

    Again, thanks for your input. If I find that the numerous piped lsof calls are putting to much of a strain on the server, I'll probably port it to a module (and CPAN it). Might be an interesting foray into the world of XS or inline c!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://464067]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-04-25 08:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found