#!/bin/bash
# Set database connection details
db_user="APPS"
db_pass="yourpassword"
db_host="yourhostname"
db_port="1521"
db_sid="yoursid"
# Set email address
email="youremail@example.com"
# Query ad_applied_patches table
patches=$(sqlplus -s $db_user/$db_pass@$db_host:$db_port/$db_sid <<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
SELECT patch_name || ' - ' || patch_type || ' - ' || creation_date FROM ad_applied_patches;
EXIT;
EOF)
# Format output as HTML table
output="<html><body><h1>List of applied patches:</h1><table><tr><th>Patch Name</th><th>Patch Type</th><th>Creation Date</th></tr>"
while read -r line; do
IFS='-' read -ra arr <<< "$line"
output+="<tr>"
for i in "${arr[@]}"; do
output+="<td>$i</td>"
done
output+="</tr>"
done <<< "$patches"
output+="</table></body></html>"
# Send email using mailx command with -S option instead of -a option
echo "$output" | mailx -S "Content-type: text/html;" -s "Patches Report" $email
Received message. If you're not getting the proper report using the current output format, you can try changing it to better suit your needs. Here's an example of how you could format the output as a table instead: ```bash #!/bin/bash # Set database connection details db_user="APPS" db_pass="yourpassword" db_host="yourhostname" db_port="1521" db_sid="yoursid" # Set email address email="youremail@example.com" # Query ad_applied_patches table patches=$(sqlplus -s $db_user/$db_pass@$db_host:$db_port/$db_sid <<EOF SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF SELECT patch_name || ' - ' || patch_type || ' - ' || creation_date FROM ad_applied_patches; EXIT; EOF) # Format output as HTML table output="<html><body><h1>List of applied patches:</h1><table><tr><th>Patch Name</th><th>Patch Type</th><th>Creation Date</th></tr>" while read -r line; do IFS='-' read -ra arr <<< "$line" output+="<tr>" for i in "${arr[@]}"; do output+="<td>$i</td>" done output+="</tr>" done <<< "$patches" output+="</table></body></html>" # Send email using mailx command with -S option instead of -a option echo "$output" | mailx -S "Content-type: text/html;" -s "Patches Report" $email ``` Does this work
No comments:
Post a Comment