A common question newbies come up with is "how can I output text to another terminal or xterm?". Well the basic idea is pretty simple: open and xterm and type "tty" in it....it should return something like "/dev/pts/5". Then all you do to send data to it is (from another xterm) type " echo 'hello foobar' > /dev/pts/5".

The following snippet uses perl to automatically find the right /dev/pts/? The biggest obstacle is getting the right pid. When you open an xterm you can get it's pid from "fork()", but then it starts bash which is another pid. I have used time() to tag the xterm so it can be found and used as the parent pid of the bash instance. The ttydev is connected to the bash pid, not the xterm pid. Otherwise, it's straight forward.

#!/usr/bin/perl use warnings; use strict; use Proc::ProcessTable; my $time = time(); my $xtermparentpid; my $pttydev; system("xterm -T $time &"); #specify title so you can match for it my $t = new Proc::ProcessTable; foreach my $p (@{$t->table}) { # print "pid->",$p->pid," ttydev->",$p->ttydev," cmdline->", # $p->cmndline," ppid->",$p->ppid,"\n"; if($p->cmndline =~ /$time/){$xtermparentpid = $p->pid} } foreach my $p (@{$t->table}) { if($p->ppid == $xtermparentpid){$pttydev = $p->ttydev} } open(FH,">$pttydev") or warn $!; for(1..1000){print STDOUT $_,"\n"; print FH $_.'a',"\n";sleep 1;} close FH;