Hi, I have a perl code that runs a ssh process that will run forever(in a loop) until it is killed. I do it by a fork and then the child process is using "open" to run the ssh, then the child process waits for the open's output and prints it on the screen, I want to print it on a canvas I opened in the original parent process.

Problem is, it's not working, i made sure that the child process has the right reference to the text widget but for some reason, the text is not displayed on the canvas.

Code:
my $TextS=$BB5_frame->Scrolled("Text", -wrap=>'none')->pack(); $BT5_frame->Button(-text => "RUN", -command=> sub { $c_pid = fork(); if (defined($c_pid) and $c_pid == 0) { $SIG{CHLD}='IGNORE'; my $flag =0; $T_pid = open(Out ,"-|" ,"/usr/bin/ssh","-x",$Ap_host,@Pre); $SIG{TERM} = sub {kill ('TERM',$T_pid); close(Out); }; while (<Out>) { $TextS->insert('end', $_); } } })->pack(-side=>'left');
When I print the lines to STDOUT it's working.

In reply to Piping output from child to parent Tk widget by Ohad

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.