From: Steve Scaffidi Date: Sat, 27 Jun 2009 06:19:15 +0000 (-0400) Subject: fixed up the demos for cleaner operation X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3326d20d1c47a94f8c71fbdc518cdd96fe2a7da5;p=urisagit%2FStem.git fixed up the demos for cleaner operation --- diff --git a/bin/chat2_demo b/bin/chat2_demo index a2006a9..9a4ec6f 100755 --- a/bin/chat2_demo +++ b/bin/chat2_demo @@ -5,6 +5,13 @@ $offset = 175 ; $base_off = 0 ; $xskip = ( $^O eq 'solaris' ) ? 600 : 500 ; +use File::Basename qw( basename ); +$ENV{PATH} .= ':' . basename( $0 ) . ':.'; +for my $prog qw( run_stem xterm telnet ) { + die "Can't find $prog in PATH\n" if + system( "which $prog >/dev/null 2>&1" ) != 0; +} + my @children ; $SIG{ 'INT' } = \&cleanup ; @@ -41,12 +48,11 @@ print "$cmd\n" ; sleep 2 unless $cmd =~ /localhost/ ; } -while( ) { +1 while wait() != -1; + +exit; - next unless /^q/i ; - cleanup() ; -} sub cleanup { diff --git a/bin/chat_demo b/bin/chat_demo index 8437913..435af50 100755 --- a/bin/chat_demo +++ b/bin/chat_demo @@ -7,6 +7,13 @@ $xskip = ( $^O eq 'solaris' ) ? 600 : 500 ; print "CHAT DEMO\n" ; +use File::Basename qw( basename ); +$ENV{PATH} .= ':' . basename( $0 ) . ':.'; +for my $prog qw( run_stem xterm telnet ) { + die "Can't find $prog in PATH\n" if + system( "which $prog >/dev/null 2>&1" ) != 0; +} + my @children ; $SIG{ 'INT' } = \&cleanup ; @@ -42,13 +49,11 @@ print "$cmd\n" ; sleep 4 unless $cmd =~ /localhost/ ; } +1 while wait() != -1; -while( ) { +exit; - next unless /^q/i ; - cleanup() ; -} sub cleanup { diff --git a/bin/hello_demo b/bin/hello_demo index 5b525c1..313c5c1 100644 --- a/bin/hello_demo +++ b/bin/hello_demo @@ -4,13 +4,15 @@ use strict ; use warnings ; our $s ; -if ( -d 'conf' && -e 'bin/run_stem' ) { +print "HELLO DEMO\n" ; - $ENV{PERL5LIB} = 'lib' ; - $ENV{PATH} = "bin:$ENV{PATH}" ; +use File::Basename qw( basename ); +$ENV{PATH} .= ':' . basename( $0 ) . ':.'; +for my $prog qw( run_stem xterm ) { + die "Can't find $prog in PATH\n" if + system( "which $prog >/dev/null 2>&1" ) != 0; } -print "HELLO DEMO\n" ; $SIG{ 'INT' } = \&cleanup ; @@ -30,12 +32,11 @@ s/:/: / for @cmd ; fork_exec( @cmd ) ; -while( ) { +1 while wait() != -1; + +exit; - next unless /^q/i ; - cleanup() ; -} sub cleanup { diff --git a/bin/inetd_demo b/bin/inetd_demo index 9116feb..9556f69 100755 --- a/bin/inetd_demo +++ b/bin/inetd_demo @@ -9,6 +9,13 @@ my @children ; print "INETD: $ENV{PATH}\n" ; +use File::Basename qw( basename ); +$ENV{PATH} .= ':' . basename( $0 ) . ':.'; +for my $prog qw( run_stem xterm telnet ) { + die "Can't find $prog in PATH\n" if + system( "which $prog >/dev/null 2>&1" ) != 0; +} + $SIG{ 'INT' } = \&cleanup ; if ( $s ) { @@ -42,13 +49,11 @@ print "CMD $cmd\n" ; sleep 4 unless $cmd =~ /localhost/ ; } +1 while wait() != -1; -while( ) { +exit; - next unless /^q/i ; - cleanup() ; -} sub cleanup { diff --git a/bin/tail_demo b/bin/tail_demo index ce04d7e..6011199 100755 --- a/bin/tail_demo +++ b/bin/tail_demo @@ -5,6 +5,13 @@ $offset = 175 ; $base_off = 0 ; $xskip = ( $^O eq 'solaris' ) ? 600 : 500 ; +use File::Basename qw( basename ); +$ENV{PATH} .= ':' . basename( $0 ) . ':.'; +for my $prog qw( run_stem xterm telnet ) { + die "Can't find $prog in PATH\n" if + system( "which $prog >/dev/null 2>&1" ) != 0; +} + my @children ; my $tail_dir = 'tail' ; @@ -45,12 +52,11 @@ EOT sleep 2 ; } -while( ) { +1 while wait() != -1; + +exit; - next unless /^q/i ; - cleanup() ; -} sub cleanup {