Oracle Scripting – How to Pass Oracle Wallet Auth to SH Script

oraclescriptingwallet

I am running an Oracle DB update script that requires password. I have Oracle wallet installed. How to pass Oracle wallet to sh script so that I don't have to enter password when running the script?

I have my sqlnet.ora

sqlnet.expire_time=60
sqlnet.inbound_connect_timeout=300
sqlnet.allowed_logon_version_server=10
sqlnet.allowed_logon_version_client=10

WALLET_LOCATION =
(SOURCE =
   (METHOD = FILE)
      (METHOD_DATA =
          (DIRECTORY = /oracle/app/oracle/product/base19/19/network/admin/wallet)
   )
)

SQLNET.WALLET_OVERRIDE = TRUE
SSL_CLIENT_AUTHENTICATION = TRUE

Credentials are correctly installed:
$ mkstore -wrl "/oracle/app/oracle/product/base19/19/network/admin/wallet" -listCredential

Oracle Secret Store Tool Release 19.0.0.0.0 - Production
Version 19.4.0.0.0
Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.

Enter wallet password:   
List credential (index: connect_string username)
1: SID USER PASSWORD

I am running a script update_sql.sh:

#!/bin/bash
sqlplus cobrball @release.sql

release.sql:

spool release.log;
exit;

Best Answer

Create an auto-login wallet.

Creating an Auto-Login Wallet

Then connect to the database using the below syntax:

sqlplus /@connect_string @release.sql

connect_strings must be the same connect_string that is stored in the wallet. Otherwise the credentials in the wallet will not be used.