0

i have a shell with an array in wich there is a list of tables of a oracle db. This is the array:

ListTabs=""
ListTabs=$ListTabs"T_Tab1\n"
ListTabs=$ListTabs"T_Tab2\n"
ListTabs=$ListTabs"T_Tab3"   
echo $ListTabs
arrArr=0
IFS=\n
for listArr in ${ListTabs[@]}; 
do 
     #echo $listArr
     MYDIR[${ARR}]=$listArr
     (( arrIdx = $ARR+ 1 ))
done

then i have a select with a sqlplus connection

sqlplus -S -L ${MYCONNCTIONDB} @${FILE_SQL}

When i try to run the shell i get the error:ORA-01017: invalid username/password; logon denied. I'm sure that the connection is correct because if i delete the array the shell goes well. Any ideas?

Atlas91
  • 5,754
  • 17
  • 69
  • 141
  • What you have shown doesn't break anything, but you haven't shown what happens to `MYDIR` or where `MYCONNECTIONDB` and `FILE_SQL` are set, and if they can be modified between the loop and the `sqlplus` call. Is the `FILE_SQL` script built from the contents of the array? Does it have a `connect` call inside it? Whatever is wrong seems to be outside the code you've shown, anyway... – Alex Poole May 15 '13 at 09:40
  • Well the array and the FILE_SQL are not connected. This is the real problem. I don't know why have this error. The shell has something like 2400 rows so i can't post it! Anyway if i delete the array part everything goes ok. I can't find a solution. – Atlas91 May 15 '13 at 10:01
  • You mean if you remove the whole block you posted above? Can you narrow it down to any particular line? I'm wondering if the IFS setting might be affecting something later in the script, for example. You're probably stuck with old-fashioned debugging though, printing the value of `${MYCONNECTIONDB}` at various places to narrow down where it changes (assuming it does). – Alex Poole May 15 '13 at 10:06
  • When i red "I'm wondering if the IFS setting might be affecting something later in the script" i've got a illumination! It was the problem! so i've make a var called: IFS_OLD=$IFS then, when the for condition finished i've restore the IFS: IFS=$OLD_IFS and goes. Thanks you ;) – Atlas91 May 15 '13 at 10:32
  • possible duplicate of [Oracle JDBC : invalid username/password (ora-01017)](http://stackoverflow.com/questions/8435234/oracle-jdbc-invalid-username-password-ora-01017) – brandizzi Apr 24 '14 at 22:14

1 Answers1

1

For your array you're setting IFS:

IFS=\n

... which will affect string interpretation later in the script as well. You can either unset IFS after your array section, or store the old value in a temporary variable before setting it (O_IFS=$IFS; IFS=\n) and revert it afterwards (IFS=$O_IFS; unset O_IFS).

Alex Poole
  • 183,384
  • 11
  • 179
  • 318