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