1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| require "gco3.pl";
#########################
#file "spawn_bash.tcl":
#########################
#spawn -noecho bash
#stty raw
#interact
#########################
use IPC::Open3;
use Symbol;
$WTR = gensym();#get reference to typeglog
$RDR = gensym();
$pid = open3($WTR, $RDR, "", 'expect spawn_bash.tcl');#spawn bash shell via expect pty/tty pair
#main program body (can be modified to customize interaction)
gco($RDR,$WTR,\*STDERR,"",'\$',1, $buffer);#read the output of the spawned shell
syswrite STDOUT, "starting sending commands to the shell\r\n";
gco($RDR,$WTR,\*STDERR,"ls -altr\r",'\$',1, $buffer);#send command to the spawned shell
syswrite STDOUT, "\r=======end plugin=======\r";
|