Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I'm looking for PERL right way decision regarding finding out by one process a fullpath to a file opened by another process.

I have a PERL script w/ several BASH code insertions. I want to rewrite some BASH code in PERL - hence this question.

This script waits (w/ the help of Term::ReadKey module) for key pressings, - undertaking file processing (say, file removal from FS). The full path to that file now is cathed as follows:

$tmp=qx#/bin/ps -AHf#;
regexp for PID
$tmp=qx#/bin/cat /proc/$1/cmdline#;
regexp for a full path to the file (to avoid some encodings troubles)

from a forked process being started w/

system( "/usr/bin/mkfifo $pipe_file && $script $pid $params &" );

- though not the best solution regarding PERL, but worked - apposed to PERL's fork function - haw pipe behaved wrong in some circumstances.

Finally, my question is, What's the best PERL practics - catching full path to a filename, opened now by one process and cacthed another? F.e.: process A opened a file, how process B can get that file full path? - Both pocesses are run on same host, under same user. Both proccess has pipe filename, or may have an ID - thus identifying itself having relation one w/ another.

Thank You for Your time and wisdom.

In reply to Finding out by one process a filename opened by another process. by humble

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (4)
    As of 2018-05-27 23:42 GMT
    Find Nodes?
      Voting Booth?