Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Well, lsof does work on multiple operating systems including Linux and Solaris. For example, lsof revision 4.74 lists information about files opened by processes for the following UNIX dialects:

AIX 5.[123] Apple Darwin 6.x and 7.x for Power Macintosh systems BSDI BSD/OS 4.3.1 for x86-based systems DEC OSF/1, Digital UNIX, Tru64 UNIX 4.0, and 5.1 FreeBSD 4.[2-9], 4.1[01], 5.[012] and 6.0 for x86-based systems FreeBSD 5.[012] and 6.0 for Alpha, AMD64 and Sparc64 based systems HP-UX 11.00 and 11.11 Linux 2.1.72 and above for x86-based systems NetBSD 1.[456] and 2.x for Alpha, x86, and SPARC-based systems NEXTSTEP 3.[13] for NEXTSTEP architectures OpenBSD 2.[89] and 3.[0123456] for x86-based systems OPENSTEP 4.x Caldera OpenUNIX 8 SCO OpenServer Release 5.0.6 for x86-based systems SCO|Caldera UnixWare 7.1.4 for x86-based systems Solaris 2.6, 8, 9 and 10

The path to where lsof is installed my vary slightly but you can modify your code to pick the right one depending on which OS you are on at the time. So McDarren's example should give you what you need.

-- vek --

In reply to Re^3: how to know the files opened by a process by vek
in thread how to know the files opened by a process by swaroop

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (12)
    As of 2014-12-26 20:10 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (175 votes), past polls