Commit | Line | Data |
4536f655 |
1 | #!/usr/local/bin/perl -s |
2 | |
3 | $line_cnt = 10 ; |
4 | $offset = 175 ; |
5 | $base_off = 0 ; |
6 | $xskip = ( $^O eq 'solaris' ) ? 600 : 500 ; |
7 | |
8 | my @children ; |
9 | |
10 | $SIG{ 'INT' } = \&cleanup ; |
11 | |
12 | if ( $s ) { |
13 | |
14 | $ssfe = 'ssfe' ; |
15 | $prompt = '-prompt Stem:' ; |
16 | $prompt2 = '-prompt Chat:' ; |
17 | $echo = 'console_echo=1' |
18 | } |
19 | |
20 | foreach $cmd ( split /\n/, <<EOT ) { |
21 | xterm -T Chat1 -n Chat1 -geometry 80x25+XSKIP+0 -e $ssfe $prompt run_stem $echo chat_server |
22 | xterm -T Chat2 -n Chat2 -geometry 80x25+XSKIP+250 -e $ssfe $prompt run_stem $echo chat_client |
23 | xterm -T A -n A -geometry 80xLINE+0+OFF -e $ssfe $prompt2 telnet localhost 6666 |
24 | xterm -T B -n B -geometry 80xLINE+0+OFF -e $ssfe $prompt2 telnet localhost 6667 |
25 | xterm -T C -n C -geometry 80xLINE+0+OFF -e $ssfe $prompt2 telnet localhost 6668 |
26 | xterm -T D -n D -geometry 80xLINE+0+OFF -e $ssfe $prompt2 telnet localhost 6669 |
27 | EOT |
28 | |
29 | $cmd =~ s/XSKIP/$xskip/ ; |
30 | |
31 | $cmd =~ s/LINE/$line_cnt/ ; |
32 | $cmd =~ s/OFF/$base_off/ and $base_off += $offset ; |
33 | |
34 | print "$cmd\n" ; |
35 | |
36 | @cmd = split ' ', $cmd ; |
37 | |
38 | s/:/: / for @cmd ; |
39 | |
40 | fork_exec( @cmd ) ; |
41 | sleep 2 unless $cmd =~ /localhost/ ; |
42 | } |
43 | |
44 | while( <STDIN> ) { |
45 | |
46 | next unless /^q/i ; |
47 | |
48 | cleanup() ; |
49 | } |
50 | |
51 | sub cleanup { |
52 | |
53 | print "clean up\n" ; |
54 | |
55 | kill 9, @children ; |
56 | wait ; |
57 | exit ; |
58 | |
59 | } |
60 | |
61 | sub fork_exec { |
62 | |
63 | my( @exec ) = @_ ; |
64 | |
65 | if ( $pid = fork() ) { |
66 | |
67 | push @children, $pid ; |
68 | return ; |
69 | } |
70 | |
71 | exec @exec ; |
72 | } |