[prog] shell script problem

Jacinta Richardson jarich at perltraining.com.au
Wed Nov 30 21:34:01 EST 2005


Noir wrote:
> I am writing this script to email me the output of a
> program. 

> Following is my script & it doesn't quite do what I
> want. I ran it with "bash -x" and it gets stuck at:
> 
> mail -s "$SUB1" $RECP
> 
> Also, I am not quite sure how to get the whole <STDIN>
> in the body of the email.
> 
> Following is the script:
> 
> #!/bin/bash
> BINARY="/usr/bin/binary"
> CHECK="`$BINARY --check | cat -b | grep 2 | awk
> {'print $9'}`"
> RECPT="noir at yahoo.com"
> SUB1="binary check for `hostname` NOT ok"
> SUB2="binary check for `hostname` OK "
> OK="okay"
> if [ "$CHECK"  != "$OK" ]; then
> 	mail -s "$SUB1" $RECPT
> else
> 	mail -s "$SUB2" $RECPT
> fi

By appearances your STDOUT is in $CHECK.  Thus you should be able to write:

if [ "$CHECK"  != "$OK" ]; then
        echo $CHECK | mail -s "$SUB1" $RECPT


All the best,

	Jacinta


-- 
   ("`-''-/").___..--''"`-._          |  Jacinta Richardson         |
    `6_ 6  )   `-.  (     ).`-.__.`)  |  Perl Training Australia    |
    (_Y_.)'  ._   )  `._ `. ``-..-'   |      +61 3 9354 6001        |
  _..`--'_..-_/  /--'_.' ,'           | contact at perltraining.com.au |
 (il),-''  (li),'  ((!.-'             |   www.perltraining.com.au   |




More information about the Programming mailing list