dimanche 28 juin 2020

If statement don't works in sh file

Good day.

I want to automatize certain process with linux and bash. And I stuck in a IF statement.

This is the code:

#!/bin/bash
result=$(
 sqlplus -s /nolog << EOF
 CONNECT admin/password@server;

 whenever sqlerror exit sql.sqlcode;
 set echo off
 set heading off
 @processQuery.sql
 exit;
 EOF
)
echo $result
if [ "$result" != "no rows selected" ]
then echo "Please, clean up"
else echo "All Ok"
fi

And the output is:

no rows selected
Please, clean up

Thanks so much for the help.

Aucun commentaire:

Enregistrer un commentaire