But there is a problem. I come from a Linux background. A command-line perspective. But most EPM environments are based on Windows, due to the Windows-only components. (I hope Oracle is working on getting these components onto Linux, they have already done that with the Financial Reporting Print Server so maybe they are heading that way.)
This just means I need to bring some command-line goodness to these dull Windows landscapes. To do this we need to be able to access some very basic information - what products are installed, in which location and so on. For this we need to set some environment variables.
You will see many batch scripts in EPM for setting the correct environment variables. They are littered all over the shop. What you see below is a (admittedly messy and hacky) script to set all the environment variables you could need. If you call this at the beginning of a script you will have your whole script environment set up. This script will form the backbone of all others I will create.
You must run this from the directory the script resides!
@echo off SET OLDDIR=%CD% REM "If HYPERION_HOME isn't set use EPM_ORACLE_HOME to set it." IF "%HYPERION_HOME%"=="" (GOTO SETHYPERIONHOME) ELSE (GOTO CONTINUE) GOTO CONTINUE REM "If EPM_ORACLE_HOME and HYPERION_HOME aren't set we have to exit." REM "If not we have to set them both to the same value." :SETHYPERIONHOME IF "%EPM_ORACLE_HOME%"=="" GOTO WEREDONE SET HYPERION_HOME=EPM_ORACLE_HOME GOTO CONTINUE :CONTINUE REM "Set the ORACLE_HOME and EPM_ORACLE_HOME variables." SET ORACLE_HOME=%HYPERION_HOME% SET EPM_ORACLE_HOME=%HYPERION_HOME% REM "Set the EPM_ORACLE_INSTANCE variable." cd /d %HYPERION_HOME% cd .. cd user_projects FOR /D %%G in ("*") DO ( IF NOT %%G=="domains" ( SET EPM_ORACLE_INSTANCE=%CD%\%%G SET EPMSYSTEM=%%G ) ) REM "Set the EPM_DOMAIN variable (if domain exists...)" IF NOT EXIST %HYPERION_HOME%\..\user_projects\domains GOTO CONTINUE2 cd domains FOR /D %%G in ("*") DO SET EPM_DOMAIN=%CD%\%%G :CONTINUE2 call %EPM_ORACLE_INSTANCE%\bin\setEnv.bat REM "Set the MIDDLEWARE_HOME and ORACLE_DIR variables." cd /d %HYPERION_HOME% cd .. SET MIDDLEWARE_HOME=%CD% SET MW_HOME=%MIDDLEWARE_HOME% cd .. SET ORACLE_DIR=%CD% REM Get JRE or JDK if exist "%EPM_ORACLE_HOME%\..\jdk160_21" ( if not "%1" == "-client" ( goto okFusionJDK ) ) if not "%1" == "32" ( if exist "%EPM_ORACLE_HOME%\common\JRE-64\Sun\1.5.0" goto okSetJRE64_150 if exist "%EPM_ORACLE_HOME%\common\JDK-64\Sun\1.4.2" goto okSetJDK64_142 if exist "%EPM_ORACLE_HOME%\common\JRE-64\Sun\1.4.2" goto okSetJRE64_142 ) if not "%1" == "64" ( if exist "%EPM_ORACLE_HOME%\common\JRE\Sun\1.6.0" goto okSetJRE160 if exist "%EPM_ORACLE_HOME%\common\JRE\Sun\1.5.0" goto okSetJRE150 if exist "%EPM_ORACLE_HOME%\common\JDK\Sun\1.4.2" goto okSetJDK142 if exist "%EPM_ORACLE_HOME%\common\JRE\Sun\1.4.2" goto okSetJRE142 ) REM No JDK found! goto end :okFusionJDK set JAVA_HOME=%EPM_ORACLE_HOME%\..\jdk160_21 goto end :okSetJRE160 echo "JRE: Sun" set JAVA_HOME=%EPM_ORACLE_HOME%\common\JRE\Sun\1.6.0 goto end :okSetJRE64_150 set JAVA_HOME=%EPM_ORACLE_HOME%\common\JRE-64\Sun\1.5.0 goto okSetJRE32JDK32 :okSetJRE150 set JAVA_HOME=%EPM_ORACLE_HOME%\common\JRE\Sun\1.5.0 goto end :okSetJDK64_142 set JAVA_HOME=%EPM_ORACLE_HOME%\common\JDK-64\Sun\1.4.2 goto okSetJRE32JDK32 :okSetJRE64_142 set JAVA_HOME=%EPM_ORACLE_HOME%\common\JRE-64\Sun\1.4.2 goto okSetJRE32JDK32 :okSetJRE142 set JAVA_HOME=%EPM_ORACLE_HOME%\common\JRE\Sun\1.4.2 goto end :okSetJDK142 set JAVA_HOME=%EPM_ORACLE_HOME%\common\JDK\Sun\1.4.2 goto end :okSetJRE32JDK32 if exist "%EPM_ORACLE_HOME%\common\JRE\Sun\1.5.0" goto okSetJRE32_150 if exist "%EPM_ORACLE_HOME%\common\JDK\Sun\1.4.2" goto okSetJDK32_142 if exist "%EPM_ORACLE_HOME%\common\JRE\Sun\1.4.2" goto okSetJRE32_142 :okSetJRE32_150 set JAVA_HOME32=%EPM_ORACLE_HOME%\common\JRE\Sun\1.5.0 goto end :okSetJRE32_142 set JAVA_HOME32=%EPM_ORACLE_HOME%\common\JRE\Sun\1.4.2 goto end :okSetJDK32_142 set JAVA_HOME32=%EPM_ORACLE_HOME%\common\JDK\Sun\1.4.2 goto end :end REM "Set the OHS instance string" IF EXIST "%EPM_ORACLE_INSTANCE%\httpConfig\ohs\bin\opmnctl.bat" ( FOR /F "tokens=*" %%i in ('findstr "OpmnService.*" %EPM_ORACLE_INSTANCE%\httpConfig\ohs\bin\opmnctl.bat') DO SET TEMPOUTPUT=%%i for /f "tokens=2 delims=_" %%a in ("%TEMPOUTPUT%") do ( set OHSINSTANCE=%%a ) ) REM "Set the Financial Reporting Studio path reg query HKLM\SYSTEM\CurrentControlSet\Services\HyS9FRPrint /v ImagePath > NUL 2>&1 IF %ERRORLEVEL% NEQ 0 GOTO done for /F "tokens=3" %%j IN ('reg query HKLM\SYSTEM\CurrentControlSet\Services\HyS9FRPrint /v ImagePath') DO SET FRPATH=%%j SET FRPATH=%FRPATH:products\financialreporting\bin\HyS9FRPrint.exe=% SET FRPATH=%FRPATH:"=% :done REM "Echo out all of the environment variables - some have been set by us and some will be pre-set :WEREDONE echo Environment Variables: echo ========================================================== echo ORACLE_DIR=%ORACLE_DIR% echo HYPERION_HOME=%HYPERION_HOME% echo ORACLE_HOME=%ORACLE_HOME% echo EPM_ORACLE_HOME=%EPM_ORACLE_HOME% echo MIDDLEWARE_HOME=%MIDDLEWARE_HOME% echo MW_HOME=%MW_HOME% echo EPM_ORACLE_INSTANCE=%EPM_ORACLE_INSTANCE% echo EPMSYSTEM=%EPMSYSTEM% echo EPM_DOMAIN=%EPM_DOMAIN% echo ARBORPATH=%ARBORPATH% echo APS_HOME=%APS_HOME% echo ESSLANG=%ESSLANG% echo ESSBASEPATH=%ESSBASEPATH% echo JAVA_HOME=%JAVA_HOME% echo OHSINSTANCE=%OHSINSTANCE% echo FR_HOME=%FR_HOME% echo FRPATH=%FRPATH% echo ========================================================== echo. cd /d %OLDDIR%
And there we go. It's not pretty, but it works. You may notice some stuff is copied from Oracle's scripts (the whole section to set the JAVA_HOME, basically) but most of it is my own work. With the environment variables set up we can do cool stuff like this:
%SystemRoot%\system32\cmd.exe /k"%EPM_DOMAIN%\bin\startWebLogic.cmd"
The above will start the WebLogic Admin Server.
explorer %FRPATH%\diagnostics\logs\FinancialReporting\
The above will open the file manager at the folder where the Financial Reporting Print Server saves its logs.
net stop "Oracle Process Manager (EPM_%EPMSYSTEM%)"
net stop "Oracle Process Manager (%OHSINSTANCE%)"
The above will stop the Essbase Server and OHS services.
Obviously you can see why this would be very useful!
If you want to download the script you can do so by clicking here.
Informative post. Thanks for sharing
ReplyDeletePPM consultants