Retrieving Oracle patches with wget

Update #1, 13-Nov-2009: While testing this patch download method in the wake of the recent My Oracle Support cutover, I noticed a new wrinkle. Instead of a successful patch download, I got the following message from wget:

Self-signed certificate encountered.
To connect to login.oracle.com insecurely, use `--no-check-certificate'.

After adding --no-check-certificate to the wget command, I was once again able to retrieve patches, but it took a bit longer than usual, as wget wandered through a tree of redirects. I've updated the code for the getOraPatch function accordingly.

Update #2, also 13-Nov-2009: A commenter on Chris Warticki's Oracle Support blog noted that the patch download page provided by the Flash version of My Oracle Support does not present a right-clickable Download button, which would seem to render the wget patch retreival method useless. Thankfully, there's a workaround: open a new window/tab in your browser, using an URL of the form https://updates.oracle.com/ARULink/PatchDetails/process_form?patch_num=nnnnnnn This will open a patch download page in a plain HTML, non-Flashy interface, and you should be all set to go!

No, no, this isn't a back door into the Metalink My Oracle Support patch repository. Don't get too excited. ;-)

While working from home this evening, I had to download some patches to a remote Linux system, and was struck, not for the the first time, by the inconvenience of it all. The usual options seem to be:

  1. Download the patches to a local machine and upload them to the remote system -- annoyingly manual at best, and downright gross when a VPN connection is involved.
  2. FTP from the remote system to updates.oracle.com. That's a tried-and true method, but still involves a lot of typing. Not anymore! This access option was disabled in November 2009, with the arrival of My Oracle Support.
  3. Start a VNC session on the remote system, launch a web browser, log in to Metalink My Oracle Support, and click the download button. Not a bad option...unless you can't use VNC for some reason, and are stuck with a command-line interface. Or if you're trying to navigate in that remote browser over a VPN connection. Not an exercise for impatient people.

When life gives you inconvenience, write a shell function!

At least, I think that's how the old saying goes. I created the following bash(1) function that uses wget to download a patch from updates.oracle.com, using the URL behind the Download button:

# Function to retreive patches from Metalink/My Oracle Support via wget
function getOraPatch {
   [[ $mosUser ]] || read -p "Oracle Support Userid: " mosUser;
   [[ $mosPass ]] || read -sp "Oracle Support Password: " mosPass;
   fname=`echo $1 | awk -F"=" '{print $NF;}'`;
   wget --no-check-certificate --http-user $mosUser --http-passwd $mosPass $1 -O $fname -nv;
   echo "Completed with status: $?"
}

The above function prompts for the username and password that you use to access Metalink My Oracle Support. If the variables are already defined in your session, then it assumes you want to use the existing values and does not prompt you again. Then, the function parses the patch URL to find the patch's filename, and passes all four values (userid, password, URL, and filename) to wget.

Usage example

  1. Load the above function into your shell session, or copy and paste the code into your .bash_profile to have it loaded when you log in.
  2. Log in to Metalink My Oracle Support and locate the patch. Can't get around this step, but you can do it in a local browser, instead of dealing with a remote X session as described above in #3.
  3. Right-click on the Download button to copy the patch URL:
    Patch download window
  4. Invoke the function, enclosing the super-long patch URL in single quotes:
    oracle@testhost:/stage> getOraPatch 'really_long_patch_URL_copied_in_previous_step'
    
  5. Answer the prompts, and lean back and watch as wget retrieves your patch:
    Oracle Support Userid: your_MyOracleSupport_login_here
    Oracle Support Password: your_MyOracleSupport_password_here
    (some wget output snipped)
    HTTP request sent, awaiting response... 200 OK
    Length: 52,028 [application/zip]
    
    100%[====================================>] 52,028        --.--K/s             
    
    22:27:24 (555.94 KB/s) - `pnnnnnnn_version_platform.zip' saved [52028/52028]
    
  6. Repeat as necessary.

Disclaimers, caveats and commentary

  1. As noted in the opening line of this post, this is not a "back door" into Oracle's patch repository. You still need a valid Metalink userid and password for this retrieval method to work. Furthermore, since this method essentially performs the same actions as clicking on a link in a browser, and requires manual collection of the patch download URL, I don't think it qualifies as "automation." I certainly didn't set out to violate the Oracle.com Terms of Use, so hopefully no one interprets this as such. :-)
  2. I've only tested this on Linux. Presumably, you could utilize this method on other Unix variants (and even Windows, if you're into that sort of thing).
  3. On Unix/Linux, make sure you enclose the patch URL in single quotes, or the shell will interpret all of the ampersands in the URL as, "wow, you want me to launch 5 or 6 background processes? O-kay!"
  4. Before copying the patch URL, make sure you've already selected the correct release and platform for the patch. The values of the aru and file_id parameters in the URL change as you select those values.
  5. You need to have wget installed on your system for this method to work as written above. It probably would be relatively easy to adapt this to use curl instead, but wget is what I thought to use first.
  6. Some versions of wget use http-password instead of http-passwd. Check wget --help to verify what's valid for your version.
  7. Using this function will leave the values of your Oracle Support userid and password in the shell variables $mosUser and $mosPass. If this makes you uncomfortable, remember to use unset on those variables, or just exit your session, when you're done downloading.
  8. If you have any characters in your password that could be interpreted as metacharacters by the shell, you might need to escape them. I didn't test that too thoroughly. :-)

A few random observations

  • Yes, I'm downloading patches on a Friday night. And it's not urgent, strictly speaking. Do I know how to live, or what?
  • According to The Google, my posting rate for the life of this blog is 0.2 posts/week. It's not every week that I get to surpass my average output by an order of magnitude.
  • On second thought, at this rate, I could post twice a week for a while and still bask in the glow of that false feeling of productivity. ;-)

17 Comments

  1. Posted 14 April 2009 at 15:01 | Permalink

    This is great!

    Now how do I upload a trace file that is 100MB in size to my SR on Metalink?

    Thanks!

  2. Posted 14 April 2009 at 17:32 | Permalink

    Hi, thanks for the comment!

    I usually just resort to the tried-and-true "Zip the large file, upload the zip file, and hope the person on the other end knows how to use an uncompress utility." (don't laugh...I once was told my trace file upload was corrupted, and had to point out that it was zipped).

    Of course, these days, the offical/correct answer is "use Oracle Configuration Manager." Specifically, the emCCR upload command takes a -diagnostic parameter that allows you to specify an SR number and path to a file on the managed system.

    Regards,

    John P.

  3. Olivier CORTANA
    Posted 22 July 2009 at 13:37 | Permalink

    Superbe technique.
    Tres tres pratique pour les patchs de 1G et +
    Bravo, et merci
    Olivier

  4. Posted 22 July 2009 at 13:57 | Permalink

    De rien, Olivier. Merci pour votre visite. :-)

    Regards,

    John P.

  5. Posted 18 November 2009 at 5:55 | Permalink

    Absolutely awesome! Using it as I write this.

    A couple of things to note about the script (that I had to do to get it to work or that I just changed):

    1- I created a shellscript instead of putting it in my "profile". Obviously, I then had to call the function at the bottom of the script. So it ended up like this:

    ===
    # Function to retreive patches from Metalink/My Oracle Support via wget
    function getOraPatch {
    [[ $mosUser ]] || read -p "Oracle Support Userid: " mosUser;
    [[ $mosPass ]] || read -sp "Oracle Support Password: " mosPass;
    fname=`echo $1 | awk -F"=" '{print $NF;}'`;
    wget --no-check-certificate --http-user $mosUser --http-passwd $mosPass $1 -O $fname;
    }

    getOraPatch $1

    ===

    (I'm hoping none of the characters got replaced by WordPress).

    2- I had to search and replace the ampersands (& or & ) in the download url to get the script not to "go into the background".

    But other than that, like I said, absolutely brilliant!

  6. Posted 18 November 2009 at 10:19 | Permalink

    Hi James,
    Great, I'm glad this is useful for you. :-) One way to get around doing search and replace on the ampersands in the patch URL is to enclose the entire URL in single quotes when you pass it to your shell script.

    As an example, I put the getOraPatch function in a shell script as you did:

    zathras:bin jpiwowar$ cat gop.sh
    #!/bin/bash
    function getOraPatch {
    [[ $mosUser ]] || read -p "Oracle Support Userid: " mosUser;
    [[ $mosPass ]] || read -sp "Oracle Support Password: " mosPass;
    fname=`echo $1 | awk -F"=" '{print $NF;}'`;
    wget --no-check-certificate --http-user $mosUser --http-passwd $mosPass $1 -O $fname;
    }

    getOraPatch $1

    Then, invoking the shell script with the URL in single quotes:

    zathras:bin jpiwowar$ ./gop.sh 'http://updates.oracle.com/Orion/Download/process_form/p6809246_R12_GENERIC.zip?file_id=24754884&aru=10006133&userid=o-me@mymail.com&email=me@mymail.com&patch_password=&patch_file=p6809246_R12_GENERIC.zip'

    --lots of wget output snipped --
    HTTP request sent, awaiting response... 200 OK
    Length: 7206368 (6.9M) [application/zip]
    Saving to: `p6809246_R12_GENERIC.zip'

    100%[======================================>] 7,206,368 1.14M/s in 6.5s

    2009-11-18 07:14:48 (1.06 MB/s) - `p6809246_R12_GENERIC.zip' saved [7206368/7206368]

    Regards,

    John P.

  7. david
    Posted 8 April 2010 at 7:00 | Permalink

    I used the above example to download a small patch from oracle, and the following error msg I got.

    Any idea?

    Connecting to updates.oracle.com[141.146.44.51]:443... connected.
    HTTP request sent, awaiting response... 301 Moved Permanently

  8. Posted 8 April 2010 at 8:18 | Permalink

    Hi David,
    I get a number of messages like that, but wget does eventually stop following redirects and download the patch. I just tested this on a small patch, and I get a series of redirects before the patch download starts:

    HTTP request sent, awaiting response... 301 Moved Permanently
    HTTP request sent, awaiting response... 302 Moved Temporarily
    HTTP request sent, awaiting response... 301 Moved Permanently
    HTTP request sent, awaiting response... 302 Found
    HTTP request sent, awaiting response... 200 OK

    I cut out a lot of output, because the URLs get a bit long, but as you can see, it bounces around a bit before the download actually starts.
    Does your wget session end after the first 301 message, or does it keep going?

    Regards,

    John P.

  9. davidchiu
    Posted 15 April 2010 at 7:34 | Permalink

    John:
    Eventually the wget session stop, and one zip file that is not the correct size compare to what oracle have.

    Didn't work...

  10. Posted 15 April 2010 at 9:53 | Permalink

    Hi David,

    Are you able to retrieve other patches with wget? I haven't seen this behavior with any of the patches I've downloaded this way. Perhaps you have some options defined in a global or local wgetrc file that are influencing wget's default operation regarding redirects.

    Regards,

    John P.

  11. david nahmias
    Posted 16 April 2010 at 2:34 | Permalink

    Thank You for the Posting!

    if someone can help,
    I am looking to download the file ofm_appdev_generic_11.1.1.2.0_disk1_1of1.zip
    to wls unix server with wget or if there is better way.

    Thank You!

    david

  12. david nahmias
    Posted 16 April 2010 at 2:37 | Permalink

    Thank You for the Posting!

    if someone can help,
    I am looking to download the file ofm_appdev_generic_11.1.1.2.0_disk1_1of1.zip
    to wls unix server with wget or if there is better way.

    the site is http://www.oracle.com/technology/documentation/middleware.html

    Thank You!

    david

  13. Posted 16 April 2010 at 15:43 | Permalink

    Hi David,

    The method described in this post covers downloadig patches from My Oracle Support, but doesn't address downloading files from Oracle Technet. OTN downloads require cookies to be set for the download session, so you'll need to copy the appropriate cookies from another browser and feed them to wget. There's a good writeup by Marc Fielding on the Pythian blog that explains how to do this: http://www.pythian.com/library/papers_and_books/downloading_from_otn_directly_to_your_database_server/

    Regards,

    John P.

  14. oli
    Posted 28 June 2010 at 8:05 | Permalink

    Resolving updates.oracle.com... 141.146.44.51
    Connecting to updates.oracle.com|141.146.44.51|:80... failed: Connection timed out.
    Retrying.

    --16:02:33-- (try: 2) http://updates.oracle.com/Orion/Download/process_form/p8202632_10205_HPUX-IA64.zip?file_id=30615228&aru=12652895&userid=olis_userid@olis_org&email=olis_email&patch_password=&patch_file=p8202632_10205_HPUX-IA64.zip
    Connecting to updates.oracle.com|141.146.44.51|:80...

    I think port 80 is blocked on this server. My network admin told me port 80 should never be open on a DB server and DB servers should never have internet access as it is too much of a security hole.

    Any comments/workarounds?

    Thanks

  15. Posted 28 June 2010 at 10:00 | Permalink

    Hi Oli,

    Since it's your network admin's job to maintain the security of your company's network, and every organization has different security requirements, I won't presume to offer any workarounds. Instead, I suggest that you engage with your network admin to explain what you're trying to do (if you haven't already), and see if he or she has any ideas about how to accomplish the task while maintaining a comfortable level of compliance. It might be possible to set up a proxy that only allows outbound connections to oracle.com, for example, but since I'm not a network guy, I might be just making things up. :-) Or maybe there's a network share on the database server that is also accessible from a server that has access to the outside world, but if your network admin is blocking outbound port 80, I doubt that this sort of this sort of thing would be allowed either.

    Depending on the work involved, you may both decide that any solution to the problem isn't worth the time and effort. If that's the case, you're stuck with copying patches up to the database server from another machine. Even then, using wget to download the patches could still save you some time, since you could batch all of the downloads into a single script, and avoid babysitting several browser sessions.

    Good luck!

    Regards,

    John P.

  16. Posted 12 December 2011 at 18:54 | Permalink

    The approach in this link works like a champ for pulling files down from technet:
    http://www.slaviks-blog.com/2009/01/09/otn-and-wget/

  17. mahi
    Posted 19 January 2012 at 12:13 | Permalink

    dude
    u r awasome....
    love u

3 Trackbacks

  1. [...] you're interested in a solution for using wget to retrieve Oracle patches, I know a guy who wrote a blog post about that very topic a while back... This entry was written by jpiwowar, posted on 17 July [...]

  2. [...] you like staying on top of fresh things, perhaps John Piwowar’s method of retrieving Oracle patches with wget would also appeal to [...]

  3. [...] of my most frequently-visited blog posts is Retrieving Oracle patches with wget. Recently, I had a commenter on that post ask about using wget to download software from Oracle [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*