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 | |
3104a1f1 |
8 | use File::Basename qw( basename ); |
9 | $ENV{PATH} .= ':' . basename( $0 ) . ':.'; |
6b34fa66 |
10 | |
3104a1f1 |
11 | for my $prog qw( run_stem xterm telnet ) { |
12 | die "Can't find $prog in PATH\n" if |
13 | system( "which $prog >/dev/null 2>&1" ) != 0; |
14 | } |
15 | |
4536f655 |
16 | my @children ; |
17 | |
18 | $SIG{ 'INT' } = \&cleanup ; |
19 | |
20 | if ( $s ) { |
21 | |
22 | $ssfe = 'ssfe' ; |
23 | $prompt = '-prompt Stem:' ; |
24 | $prompt2 = '-prompt Chat:' ; |
25 | $echo = 'console_echo=1' |
26 | } |
27 | |
28 | foreach $cmd ( split /\n/, <<EOT ) { |
29 | xterm -T Chat1 -n Chat1 -geometry 80x25+XSKIP+0 -e $ssfe $prompt run_stem $echo chat_server |
30 | xterm -T Chat2 -n Chat2 -geometry 80x25+XSKIP+250 -e $ssfe $prompt run_stem $echo chat_client |
31 | xterm -T A -n A -geometry 80xLINE+0+OFF -e $ssfe $prompt2 telnet localhost 6666 |
32 | xterm -T B -n B -geometry 80xLINE+0+OFF -e $ssfe $prompt2 telnet localhost 6667 |
33 | xterm -T C -n C -geometry 80xLINE+0+OFF -e $ssfe $prompt2 telnet localhost 6668 |
34 | xterm -T D -n D -geometry 80xLINE+0+OFF -e $ssfe $prompt2 telnet localhost 6669 |
35 | EOT |
36 | |
37 | $cmd =~ s/XSKIP/$xskip/ ; |
38 | |
39 | $cmd =~ s/LINE/$line_cnt/ ; |
40 | $cmd =~ s/OFF/$base_off/ and $base_off += $offset ; |
41 | |
42 | print "$cmd\n" ; |
43 | |
44 | @cmd = split ' ', $cmd ; |
45 | |
46 | s/:/: / for @cmd ; |
47 | |
48 | fork_exec( @cmd ) ; |
49 | sleep 2 unless $cmd =~ /localhost/ ; |
50 | } |
51 | |
3104a1f1 |
52 | 1 while wait() != -1; |
53 | |
54 | exit; |
4536f655 |
55 | |
4536f655 |
56 | |
4536f655 |
57 | |
58 | sub cleanup { |
59 | |
60 | print "clean up\n" ; |
61 | |
62 | kill 9, @children ; |
63 | wait ; |
64 | exit ; |
65 | |
66 | } |
67 | |
68 | sub fork_exec { |
69 | |
70 | my( @exec ) = @_ ; |
71 | |
72 | if ( $pid = fork() ) { |
73 | |
74 | push @children, $pid ; |
75 | return ; |
76 | } |
77 | |
78 | exec @exec ; |
79 | } |