ERROR CHECKING !!

Posted by moata_u on Ask Ubuntu See other posts from Ask Ubuntu or by moata_u
Published on 2011-03-07T16:15:17Z Indexed on 2011/03/07 16:18 UTC
Read the original article Hit count: 253

Filed under:
|

am trying catch any error when run command in order to write an log file / report
i was trying write this code :
FUNCTION FOR VALIDATION

function valid (){

if [ $? -eq 0 ]; then
 echo "$var1" ": status : OK" 
 else echo "$var1" ": status : ERROR"   
fi

COMMAND FUNCTION

function save(){

 sed -i "/:@/c connection.url=jdbc:oracle:thin:@$ip:1521:$dataBase" $search
 var1="adding database ip"
 valid $var1

 sed -i "/connection.username/c connection.username=$name" #$search
 retval=$?
 var1="addning database SID"
 valid $var1 $retval
}
save

OUTPUT

adding database ip : status : OK
sed: no input file

i want out put in this way:

adding database ip : status : OK
sed: no input file : status : ERROR"

(OR)

adding database ip : status : OK
addning database SID : status : ERROR"

I was tried toooo much but not working with me :(((

© Ask Ubuntu or respective owner

Related posts about bash

Related posts about commands