Create pfile v2

 #!/bin/bash


OUTPUT_DIRECTORY="$1"


# Get the current timestamp

CURRENT_TIMESTAMP=$(date +"%Y%m%d_%H%M%S")


# Define the path for the new folder

NEW_FOLDER="$OUTPUT_DIRECTORY/$CURRENT_TIMESTAMP"


# Create the new folder

mkdir -p "$NEW_FOLDER"


# Function to create pfile

create_pfile() {

    local output_directory="$1"

    local oracle_sid="$2"

    

    source oraenv <<< "$oracle_sid" > /dev/null


    result=$(sqlplus -S / as sysdba <<EOF

create pfile='$output_directory/init_$oracle_sid.ora' from spfile;

exit;

EOF

)

}


# Loop through Oracle SIDs and create pfiles in the new folder

for SID in $(ps -ef | grep '[o]ra_smon' | awk '{print $NF}' | cut -d '_' -f3); do

    create_pfile "$NEW_FOLDER" "$SID"

done


echo "Pfiles created successfully in $NEW_FOLDER."

Comments

Popular posts from this blog

Oratab Entries validate and add

deployment pre patch

Golden gate v1