Note that you pass references to the start methods:
# starting the application my $handle = start \@args, \$in, \$out, \$err;

After the fact, those references are lost for you, since you don't save them. Then you store copies of the scalars $in, $out, $err into the hash %client_descr for later use. But alas, those values don't have any connection with the handles IPC::Run operates with. So you are using a $out later that isn't the one IPC::Run is using.

To fix that, either make your $in, $out, $err into references first and store those -

my ($in, $out, $err); for($in,$out,$err) { $_ = \my $x } # starting the application my $handle = start \@args, $in, $out, $err; # wait until prompted for input pump $handle until $$out =~ /Login:/; # note the dereferencing +- $$out $in .= "Boris\n"; # wait until prompted for password pump $handle until $$out =~ /Password:/; # and so on ... # store them $client_descr->{"Handle"} = $handle; $client_descr->{"In"} = $in; $client_descr->{"Out"} = $out; $client_descr->{"Err"} = $err;

- then you can use them in another sub too:

$in .= "new data\n"; pump $handle until $$out =~ /data arrived:/; # note the dereferencing +- $$out print $$out;

- or store references to those scalars into your hash:

$client_descr->{"Handle"} = $handle; $client_descr->{"In"} = \$in; $client_descr->{"Out"} = \$out; $client_descr->{"Err"} = \$err; # later ... my ($handle, $in, $out) = ($client_descr->{"Handle"}, $client_descr->{ +"In"}, $client_descr->{"Out"}); $in .= "new data\n"; pump $handle until $$out =~ /data arrived:/; # note the dereferencing +- $$out print $$out;

Here the references IPC::Run operates with and those stored in the hash are different, but that is okay since both point to the same my scalars, which won't get destroyed until the references IPC::Run and your %client_descr hold are released.

You must use scalar dereferencing in "the other sub" since you cannot force $out in "the other sub" to have the same address as the original $out declared as a my variable in the first place, from which a reference was taken to pass it to start of IPC::Run.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

In reply to Re: Problems with IPC::Run module on Windows XP by shmem
in thread Problems with IPC::Run module on Windows XP by laoboss

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.