Tuesday, December 21, 2021

Pass Username & Password On Command Line To any utility

The goal of this small article is to answer how to pass the apps password on the command line to the utilities like sqlplus, adcgnjar, etc.

Use the following command:

$ { sleep 1s; echo apps; sleep 1s; echo appspassword;} | adcgnjar
$ { sleep 1s; echo apps; sleep 1s; echo appspassword;} | sqlplus

NOTE: The first "echo" instruction should contain the apps user name and second the password.

For example,

[ed-olraclin01@oracle ~]$ { sleep 1s; echo apps; sleep 1s; echo appspasswordHere;} | adcgnjar

[ed-olraclin01@oracle ~]$ { sleep 1s; echo apps; sleep 1s; echo appspasswordHere;} | sqlplus

SQL*Plus: Release 10.1.0.5.0 - Production on Tue Dec 21 13:18:05 2021

Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Enter user-name: Enter password:
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
SQL> Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
[ed-olraclin01@oracle ~]$

-->Below statement will run the SQL script present in a specific directory after it connects as APPS user,

[ed-olraclin01@oracle ~]$ { sleep 1s; echo appspasswordHere;} | sqlplus APPS @$HOME/AnyScriptToBeRun.sql

Note after it connects and run the script it exits and come back to the OS command prompt.