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:When I print the lines to STDOUT it's working.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');
In reply to Piping output from child to parent Tk widget by Ohad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |