Unix write command takes STDIN, and sends out the message.

Better use one of the IPC solutions. You can use open3 or other IPC solutions documented in perlipc. The benefit of using open3 is that it enables you to read from STDERR, and some implementation of write command does produce useful errors through STDERR.

The following code is not tested, and is only used to demo the idea:

my $pid = open3(\*WRITER, \*READER, \*READER, "write", "receiver", "te +rminal"); #receiver's name is passed as a parameter to open3 call print WRITER $ +msg; #read STDERR for possible error msg's waitpid($pid, 1);

It is important to waitpid on your child process, otherwise zombies could be created.

write command can take one or two parameters, and the second one identifies the terminal, as one user can logon to multiple terminals. In case the user logon to multiple terminals, and you don't provide terminal name, the system would pick the one with the shortest idle time.


In reply to Re: unix write command through system by pg
in thread unix write command through system by Jimbobbob

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!
  • 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, details, 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, summary, 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.