Wednesday, 13 May 2026

Automating Password Resets with a Shell Script

In non-production environments (like Dev or Test), manually typing passwords into interactive prompts is inefficient. You can automate AFPASSWD using a simple wrapper script that pipes the inputs.


Prepare automation script as name  reset_ebs_pwd.sh using below script.

--------------------------------------------------------------------------------------------------------------------

   #!/bin/bash

# ====================================================================

# Script: reset_ebs_pwd.sh

# Purpose: Automate APPS & SYSADMIN password reset in EBS R12.2

# ====================================================================

# Usage check

if [ "$#" -ne 3 ]; then

    echo "Usage: $0 <CURRENT_APPS_PWD> <NEW_APPS_PWD> <NEW_SYSADMIN_PWD>"

    exit 1

fi

CURR_APPS=$1

NEW_APPS=$2

NEW_SYS=$3


echo "Step 1: Resetting APPS Schema Password..."

# We use printf to feed the current password, then the new password twice

printf "${CURR_APPS}\n${NEW_APPS}\n${NEW_APPS}" | AFPASSWD -s APPS


if [ $? -eq 0 ]; then

    echo "SUCCESS: APPS password updated."

else

    echo "ERROR: Failed to update APPS password."

    exit 1

fi

echo "Step 2: Resetting SYSADMIN User Password..."

# SYSADMIN reset requires the APPS password first

printf "${NEW_APPS}\n${NEW_SYS}\n${NEW_SYS}" | AFPASSWD -f SYSADMIN

echo "Done! Please test login via Browser and SQL*Plus."

=======================================================================

How to Use This in Your Post

  1. Safety First: Add a "Pro-Tip" warning that automation should only be used in Non-Prod environments to avoid exposing sensitive passwords in process logs or command history.

  2. Permissions: run chmod +x reset_ebs_pwd.sh before executing.

  3. Command History: Advise users to run history -c after using the script to clear the passwords from the terminal history.

No comments:

Post a Comment

Automating Password Resets with a Shell Script

In non-production environments (like Dev or Test), manually typing passwords into interactive prompts is inefficient. You can automate AFPAS...