error in if statement
Hi,
This is my script to catch any oracle errors. In this, the $sqlerr returns ORA-01017: invalid username/password; logon denied when i specify wrong username/password the if condition is failing. how can i resolve the issue. The if statement gives error [: too many arguments sqloutput=`sqlplus -s -L $dasDBConnectString @$SqlFiles/testSQLConnection.sql` sqlerr=`echo "$sqloutput" | grep "ORA-"` echo $sqlerr if [ -n $sqlerr ] #sql connection error then Status=10 else Status=$? fi |
Hi
try this : Quote:
|
There are spaces in $sqlerr so it needs to be enclosed in quotes. Try
if [ -n "$sqlerr" ] |
Any time if you get the following error means the
"if" statement has string (with spaces) "The if statement gives error [: too many arguments" Example: a="hi hw are you" if [ -n $a ] ;then <--- will give error echo blah else echo blah fi Put in double quotes a="hi hw are you" if [ -n "$a" ] ;then <--- works fine echo blah else echo blah fi |
All times are GMT -5. The time now is 08:42 AM. |