moved demo scripts and docs into the demo directory
[urisagit/Stem.git] / bin / demo / hello_demo
1 #!/usr/local/bin/perl -s
2
3 use strict ;
4 use warnings ;
5 our $s ;
6
7 print "HELLO DEMO\n" ;
8
9 use File::Basename qw( basename );
10 $ENV{PATH} .= ':' . basename( $0 ) . ':./bin:.';
11 for my $prog qw( run_stem xterm ) {
12     die "Can't find $prog in PATH\n" if
13         system( "which $prog >/dev/null 2>&1" ) != 0;
14 }
15
16
17 $SIG{ 'INT' } = \&cleanup ;
18
19 my @children ;
20
21 my $ssfe = $s ? 'ssfe -prompt Stem:' : '' ;
22 my $echo = $s ? 'console_echo=1' : '' ;
23
24 my $cmd = <<CMD ;
25 xterm -T Hello -n Hello -geometry 80x40+0+0 -e $ssfe run_stem $echo hello
26 CMD
27
28 print "$cmd\n" ;
29
30 my @cmd = split ' ', $cmd ;
31 s/:/: / for @cmd ;
32
33 fork_exec( @cmd ) ;
34
35 1 while wait() != -1;
36
37 exit;
38
39
40
41 sub cleanup {
42
43         print "clean up\n" ;
44
45         kill 9, @children ;
46
47         wait ;  
48         exit ;
49
50 }
51
52 sub fork_exec {
53
54         my( @exec ) = @_ ;
55
56         if ( my $pid = fork() ) {
57
58                 push @children, $pid ;
59                 return ;
60         }
61
62         exec @exec ;
63 }