Press "Enter" to skip to content

Shell Script Example to Prompt for a Password in Linux

In Linux, use read command with -s option to read, hide and store password into a variable. Below is a shell script example, in which it will prompt for a password for Oracle database user SYSTEM, and after logging into the database, it will display the version information of Oracle.

Shell Script Example to Prompt for a Password

echo "Enter password for user System: "
read -s system_pw
sqlplus -S system/$system_pw@//YourIP/orcl << EOF
set pagesize 0 linesize 80 feedback off

  FROM v$version;



$ ./


Enter password for user System: 
Oracle Database 11g Enterprise Edition Release - 64bit Production
PL/SQL Release - Production
CORE	Production
TNS for 64-bit Windows: Version - Production
NLSRTL Version - Production

See also:

Vinish Kapoor

Hi, I am a full stack developer and writing about development. I document everything I learn and help thousands of people. is created, written, and maintained by me; it is built on WordPress, and hosted by Bluehost. Connect with me on Facebook, Twitter, GitHub, and get notifications for new posts.

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *