Cleaned up demos, various build fixes
[urisagit/Stem.git] / bin / demo / tail_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
15my @children ;
16
17my $tail_dir = 'tail' ;
18
19$SIG{ 'INT' } = \&cleanup ;
20
21if ( $s ) {
22
23 $ssfe = 'ssfe' ;
3e03d89e 24 $prompt = '-prompt "Stem: "' ;
4536f655 25 $echo = 'console_echo=1'
26}
27
28-d $tail_dir or mkdir $tail_dir, 0722 or
29 die "can't create $tail_dir working directory" ;
30
31foreach my $log ( qw( foo bar bar_status ) ) {
32 unlink "$tail_dir/$log.log" ;
33}
34
35
36foreach $cmd ( split /\n/, <<EOT ) {
3e03d89e 37xterm -T Archive -n Archive -geometry 80x35+0+0 -e $ssfe $prompt run_stem conf_path=$conf_path $echo archive
38xterm -T Monitor -n Monitor -geometry 80x35+$xskip+0 -e $ssfe $prompt run_stem conf_path=$conf_path $echo monitor
4536f655 39xterm -T Tail -n Tail -geometry 80x20+275+420
40EOT
41
42 print "$cmd\n" ;
43
4536f655 44 chdir $tail_dir unless $cmd =~ /run_stem/ ;
45
3e03d89e 46 fork_exec( $cmd ) ;
4536f655 47
48 sleep 2 ;
49}
50
3104a1f1 511 while wait() != -1;
52
53exit;
4536f655 54
4536f655 55
4536f655 56
57sub cleanup {
58
59 print "clean up\n" ;
60
61 kill 9, @children ;
62 wait ;
63 exit ;
64
65}
66
67sub fork_exec {
68
3e03d89e 69 my( $exec ) = @_ ;
4536f655 70
71 if ( $pid = fork() ) {
72
73 push @children, $pid ;
74 return ;
75 }
76
3e03d89e 77 exec $exec ;
4536f655 78}