Skip to content

Instantly share code, notes, and snippets.

Last active July 28, 2022 15:52
Show Gist options
  • Save psadmin-io/0c8f617ac3c7dc41fadc to your computer and use it in GitHub Desktop.
Save psadmin-io/0c8f617ac3c7dc41fadc to your computer and use it in GitHub Desktop.
A modified version of Oracle's script to download PeopleSoft Images from Oracle Support.
rem ---------------------------------------------------------------------------
rem Usage: wget-batch.bat <inputFile> <email> <password>
rem <inputFile> is a plain text file that has the URL and Output Filename
rem separated by a comma (no spaces)
rem Dan Iverson - 2015-06-12
rem This script takes 3 parameters: inputFile, email, password.
rem Filename is a text file with URL,Filename from the Oracle script.
rem Email and Password are your Oracle Support login credentials.
rem The script assumes you have WGET for Windows installed at
rem c:\wget-1.11.4-1-bin
rem ---------------------------------------------------------------------------
rem Input file with "URL,Filename"
set LIST=%1
rem SSO username and password
rem Path to wget command
set WGET=c:\wget-1.11.4-1-bin\bin\wget.exe
rem Output directory and file
set OUTPUT_DIR=c:\temp
rem Location of cookie file
set COOKIE_FILE=%OUTPUT_DIR%\pum.cookies
rem Log directory and file
set LOGDIR=c:\temp
set LOGFILE=$%LOGDIR%\wgetlog-pumdownload.log
rem End of user configurable variable
rem Contact updates site so that we can get SSO Params for logging in
%WGET% --user-agent='Mozilla/5.0' --no-check-certificate -o %OUTPUT_DIR%\output.txt
rem Find the Location part of the response
for /F "delims=" %%a in ('findstr "Location" %OUTPUT_DIR%\output.txt') do @set SSO_RESPONSE=%%a
rem Strip the first and last portions (split by a space character)
for /f "tokens=1,2,3 delims= " %%a in ("%SSO_RESPONSE%") do @set location=%%b
rem Create the SSO_SERVER variable (by finding the first two instances of 'p')
for /f "tokens=1-2,3 delims=p" %%a in ("%location%") do @set server1=%%a&@set server2=%%b
set SSO_SERVER=%server1%p%server2%
rem Create the SSO_TOKEN variable (by finding everything after the '=')
for /f "tokens=2 delims==" %%a in ("%location%") do @set SSO_TOKEN=%%a
set SSO_AUTH_URL=sso/auth
set AUTH_DATA="ssousername=%SSO_USERNAME%&password=%SSO_PASSWORD%&site2pstoretoken=%SSO_TOKEN%"
rem The following command to authenticate uses HTTPS. This will work only if the wget in the environment
rem where this script will be executed was compiled with OpenSSL. Remove the --secure-protocol option
rem if wget was not compiled with OpenSSL
rem Depending on the preference, the other options are --secure-protocol= auto|SSLv2|SSLv3|TLSv1
%WGET% --user-agent='Mozilla/5.0' --secure-protocol=auto --no-check-certificate --post-data %AUTH_DATA% --save-cookies=%COOKIE_FILE% --keep-session-cookies %SSO_SERVER%%SSO_AUTH_URL% -O sso.txt
for /f "delims=, tokens=1,2" %%a in (%LIST%) do (
%WGET% --user-agent="Mozilla/5.0" --no-check-certificate --load-cookies=%COOKIE_FILE% --save-cookies=%COOKIE_FILE% --keep-session-cookies "%%a" -O %OUTPUT_DIR%/%%b
del sso.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment