Shell Help

Ash Berlin ash_cpan at firemirror.com
Mon May 14 21:48:58 BST 2007


Simon Wistow wrote:
> In a shell script I'm launching an app which is particularly chatty and 
> wants to spew a load of stuff to the command line as it starts up. 
> Unfortunately it also spews its error messages to stdout WHICH MAKES 
> SIMON ANGRY.
> 
> My solution is
> 
>     output=`chatty_app`;
>     if [ -z "$!" ]
>     then
>        echo "Erk - failure!";
>        echo "$output";
>     fi
> 
> 
> And all is well and good. The problem is that chatty_app also doesn't 
> background itself but putting 
> 
>     output=`chatty_app &`;
> 
> 
> doesn't work i.e it never gets to the test so non of the other stuff I 
> want running (which must run after chatty_app) works.
> 
> Anybody got any ideas?
> 
> Simon
> 
> 
> 
>    
>

#!/bin/bash

./blah.sh > foo.$$ &

echo waiting
wait
output=$(cat foo.$$) && rm foo.$$
echo output is $output

Where blah.sh for testing was:

#!/bin/bash

echo "Blah blah blah"
sleep 2
echo "Bad app - no cookie"

Good enough?

-ash


More information about the london.pm mailing list