WGET shell Script for downloading patches

What I have to offer this time is a script using which you can download patches using WGET from Meta.....oops, from My Oracle Support, I should say!


This script needs (or accepts) the following parameters:


1. Me...oops...MOS Username
2. MOS (I got it right this time!) password
3. Patch file name
4. ARU Number

You can get 3 and 4 in the following way:


Using MOS:

Query for the particular patch, click on the download link, click on WGET Options on the left side bottom corner and then copy the WGET script to clipboard. That script will have both the patch name and the ARU number.


Using HTML (supporthtml.oracle.com):

Query for the particular patch, click on the patch, then RIGHT CLICK on the patch zip file link and click on copy shortcut in IE (or copy link location in Mozilla Firefox). This link will have both the patch file name and the ARU number.

Using the classic patches window:

Query for the particular patch, then RIGHT CLICK on the DOWNLOAD button and click on copy shortcut in IE (or copy link location in Mozilla Firefox). This link will have both the patch file name and the ARU number.


I do understand that this is a roundabout process but I believe it is better than downloading the file to your desktop and then uploading to the server.

I am also working on a script to retrieve the aru number and the patch file name given the patch number. But I have had no success so far. If anyone has that script or any better script to download patches, please do not hesitate to share it.

WGET SCRIPT:

#!/bin/sh



# Start of user configurable variables

#



# SSO username and password

printf "\n\nEnter the SSO USERNAME for Metalink:\t"

read SSO_USERNAME

printf "\n\n\n\nEnter the SSO PASSWORD for Metalink:\t"

##SSO_PASSWORD="password"

stty -echo

read SSO_PASSWORD

stty echo



# E-Delivery token

EPD_TOKEN=







# Path to wget command

WGET=/usr/bin/wget



# Location of cookie file

COOKIE_FILE=/tmp/$$.cookies



# Log directory and file

LOGDIR=.

LOGFILE=$LOGDIR/wgetlog-`date +%d-%b-%y-%H-%M`.log



# Output directory and file

OUTPUT_DIR=.



## Added by Praveen B K, for customising the script.

printf "\n\nEnter the PATCH FILE NAME:\t"

read PATCH_FILE_NAME



printf "\n\nEnter the aru number:\t"

read ARU



#

# End of user configurable variable

#



if [ "$SSO_USERNAME " = " " ]

then

printf "\n\nSSO USERNAME cannot be null. Exiting............\n\n\n"

exit 1

fi



if [ "$SSO_PASSWORD " = " " ]

then

printf "\n\nSSO PASSWORD cannot be null. Exiting............\n\n\n"

exit 1

fi



if [ "$PATCH_FILE_NAME " = " " ]

then

printf "\n\nPATCH FILE NAME cannot be blank. Exiting............\n\n\n"

exit 1

fi



if [ "$ARU " = " " ]

then

printf "\n\naru number cannot be blank. Exiting............\n\n\n"

exit 1

fi



# Contact updates site so that we can get SSO Params for logging in

SSO_RESPONSE=$($WGET https://updates.oracle.com/Orion/Services/download 2>&1grep Location)



# Extract request parameters for SSO

SSO_TOKEN=`echo $SSO_RESPONSE cut -d '=' -f 2cut -d ' ' -f 1`

SSO_SERVER=`echo $SSO_RESPONSE cut -d ' ' -f 2cut -d 'p' -f 1,2`

SSO_AUTH_URL=sso/auth

AUTH_DATA="ssousername=$SSO_USERNAME&password=$SSO_PASSWORD&site2pstoretoken=$SSO_TOKEN"



# The following command to authenticate uses HTTPS. This will work only if the wget in the environment

# where this script will be executed was compiled with OpenSSL. Remove the --secure-protocol option

# if wget was not compiled with OpenSSL

# Depending on the preference, the other options are --secure-protocol= autoSSLv2SSLv3TLSv1

$WGET --secure-protocol=auto --post-data $AUTH_DATA --save-cookies=$COOKIE_FILE --keep-session-cookies $SSO_SERVER$SSO_AUTH_URL -O sso.out >> $LOGFILE 2>&1



rm -f sso.out



$WGET --load-cookies=$COOKIE_FILE --save-cookies=$COOKIE_FILE --keep-session-cookies "https://updates.oracle.com/Orion/Services/download/${PATCH_FILE_NAME}?aru=${ARU}&patch_file=${PATCH_FILE_NAME}" -O $OUTPUT_DIR/${PATCH_FILE_NAME} >> $LOGFILE 2>&1





# Cleanup

rm -f $COOKIE_FILE



Comments

Popular posts from this blog

java.lang.ExceptionInInitializerError while trying to Access login page

Solution to "End Program - WMS Idle"