How to get nicer error-messages in this bash-script?
- by moata_u
I'm trying to catch any error when run a command in order to write a log-file / report
I've tried this code:
function valid (){
if [ $? -eq 0 ]; then
echo "$var1" ": status : OK"
else echo "$var1" ": status : ERROR"
fi
}
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
var1="addning database SID"
valid $var1
}
save
The output looks like this:
adding database ip : status : OK
sed: no input file
But I want it to look like this:
adding database ip : status : OK
sed: no input file : status : ERROR"
or this:
adding database ip : status : OK
addning database SID : status : ERROR"
I've been trying, but it's not working with me. :(