Shell Script + GoldenGate (Logdump utility)
Can anyone help me in this?
As we know in oracle goldengate using Logdump utility we can retrieve the previous RBA by these commands.
open <trail file>
pos <current RBA>
sfh prev
it gives previous RBA
Now I want to extract this RBA using shell script. And I want to save this RBA for the further use.
Can anybody help me out?
Pass in the RBA as input. Shift arguments, or prompt for user input.
#!/bin/ksh
./logdump << EOF
open ./dirdat/rt000016
pos 0
n
EOF
[oracle@oel32 ggs]$ chmod 744 dolog.ksh
[oracle@oel32 ggs]$ dolog.ksh
Oracle GoldenGate Log File Dump Utility
Version 11.1.1.0.0 Build 078
Copyright (C) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
Logdump 253 >Current LogTrail is /u01/app/ggs/dirdat/rt000016
Logdump 254 >Reading forward from RBA 0
Logdump 255 >
2011/02/16 21:39:05.787.043 FileHeader Len 1557 RBA 0
Name: FileHeader
3000 0416 3000 0008 4747 0d0a 544c 0a0d 3100 0002 | 0...0...GG..TL..1...
0002 3200 0004 2000 0000 3300 0008 02f1 c2a6 6f00 | ..2... ...3.......o.
7ea3 3400 0021 001f 7572 693a 6f65 6c33 323a 6163 | ~.4..!..uri:oel32:ac
6d65 3a63 6f6d 3a3a 7530 313a 6170 703a 6767 7335 | me:com::u01:app:ggs5
0002 7535 0000 2100 1f75 7269 3a6f 656c 3332 3a61 | ..u5..!..uri:oel32:a
636d 653a 636f 6d3a 3a75 3031 3a61 7070 3a67 6773 | cme:com::u01:app:ggs
3500 0021 001f 7572 693a 6f65 6c33 323a 6163 6d65 | 5..!..uri:oel32:acme
Logdump 256 >[oracle@oel32 ggs]$
Similar Messages
-
Help Read:shell script using CONCSUB utility
I have a shell script that will re registered as a conc prgm and then this shell script will inturn call another CONC PGM which is a report. Due to some secuirty issues we have to do this way,
But my problem is the Printer parameters that are passed on to the shell script need to be passed to the conc pgm which generates the report..
Plzz help me .. this is the code that calls the CONC PGM , which is a report
NMHR_REQUEST_ID=`echo $FCP_LOGIN | cut -d"/" -f2 |
CONCSUB APPS "$RESP_APPL_NAME" "$P_RESP_NAME" $USERNAME WAIT=Y CONCURRENT $APPL_NAME '"TAX_EXEMPT"' "$P_LOCATION"` PRINTER='"$VAL_PRINTER"' NUMBER_OF_COPIES='"$VAL_NOC"' PRINT_STYLE='"$VAL_PRINT_STYLE"' LANGUAGE='"$VAL_LANGUAGE"'
Plzz help. if there is anything wrong..
Thanks in advance..Hi,
Following is the sample for using printer setting.
CONCSUB apps/apps
SYSADMIN "System Administrator" SYSADMIN
WAIT=Y
CONCURRENT FND FNDSCARU
LANGUAGE=FRENCH
PRINTER=hplj4l
NUMBER_OF_COPIES=1
PRINT_STYLE=LANDSCAPE
What is the error message?
Regards
Prashant Pathak -
Shell script using CONCSUB utility
I'm trying to run a shell script using CONCSUB. I've checked several documents on metalink related to CONCSUB but didn't find an example to run a shell scripts using CONCSUB. Can someone post an example please. I would really appreciate it.
From Metalink note 240718.1
For a concurrent program defined via "Define Concurrent Program" form
but submitted via CONCSUB, the following parameters can be used by CONCSUB :
PRINTER=<printer name>
NUMBER_OF_COPIES=<number of reports to be printed>
PRINT_STYLE=<printer style to be used>
LANGUAGE=<language to be used>
Sample:
CONCSUB apps/apps SYSADMIN "System Administrator" SYSADMIN \
WAIT=Y CONCURRENT FND FNDSCARU LANGUAGE=FRENCH \
PRINTER=hplj4l NUMBER_OF_COPIES=1 \
PRINT_STYLE=LANDSCAPE
Note: the others parameters which can be used with CONCSUB
are described in the "System Administration User Guide" as follow :
$ CONCSUB <APPS username>/<APPS password> \
<responsibility application short name> \
<responsibility name> \
<username> \
[WAIT=N|Y|<n seconds>] \
CONCURRENT \
<program application short name> \
<program name> \
[PROGRAM_NAME=<description>] \
[REPEAT_TIME=<resubmission time>] \
[REPEAT_INTERVAL= <number>] \
[REPEAT_INTERVAL_UNIT=< resubmission unit>] \
[REPEAT_INTERVAL_TYPE=< resubmission type>] \
[REPEAT_END=<resubmission end date and time>] \
[START=<date>] \
[IMPLICIT=< type of concurrent request> \
[<parameter 1> ... <parameter n>]
For parameters that follow the CONCURRENT parameter and include
spaces, enclose the parameter argument in double quotes, then again in
single quotes. -
Shell Script CONCSUB Utility Completion Status
Hi All ,
I'm trying to call a concurrent program from a shell script using CONCSUB utility. Is there a way to wait for the concurrent program to be completed in the shell script and get the RETCODE value which the concurrent program is returning?
My Current Code is something like this:
v_conc_request2=`CONCSUB XXCONC/xfunct1on '"'$APPL_SHORT_NAME'"' '"'$RESP_NAME'"' \
$userName WAIT=15 CONCURRENT XXXX XXCXXXXXX \
'"'$CURRDATE'"' '"'ALL-XXXPRD'"'`
v_conc_id2=`echo $v_conc_request2 | cut -f3 -d" "`
echo "v_conc_id2: "$v_conc_id2
if [ $? -ne 0 ]; then
errorMessage="Error while submitting the concurrent request for Downstream"
echo $errorMessage
echo $errorMessage | mailx -s "Automated Currency Rates Load Failure- DownStream" -n "$email"
exit 1
else
echo "Concurrent Program Successfully submitted for ALL Downstream Environments"
fi
fi
This is working fine but its only getting the request id i want to get the return status of the concurrent program. Since my logic is based on the return status of the concurrent program i need to do some logic.
Appreciate your help on this one.
Thanks in advance!for those who wanted the solution, here it is..
v_conc_request1=`CONCSUB XXCONC/xfunct1on '"'$APPL_SHORT_NAME'"' '"'$RESP_NAME'"' \
$userName WAIT=15 CONCURRENT XXXX XXXXGEDLRTLD \
'"'$CURRDATE'"' '"'XXXXX'"'`
v_conc_id1=`echo $v_conc_request1 | cut -f3 -d" "`
echo "v_conc_id1: "$v_conc_id1
CONC_STATUS=`sqlplus -s $1 <<!
SET feedback OFF;
SET head OFF;
SET pages 0;
SET lines 300;
SET feedback OFF;
SET term OFF;
WHENEVER SQLERROR EXIT FAILURE;
SELECT phase_code || ',' ||
status_code
FROM FND_CONCURRENT_REQUESTS fcr
WHERE request_id = $v_conc_id1;
exit
!`
export PHASE_CODE=`echo $CONC_STATUS | cut -d',' -f1`
export STATUS_CODE=`echo $CONC_STATUS | cut -d',' -f2`
echo phase_code : $PHASE_CODE
echo status_code : $STATUS_CODE
if [ "$PHASE_CODE" = 'C' ] && [ "$STATUS_CODE" = 'E' ]; then
errorMessage="Error while submitting the concurrent request for XXXX"
echo $errorMessage
echo $errorMessage | mailx -s "Automated XXXCurrency Rates Load Failure- XXXX" -n "$email"
exit 1
else
echo completed normally
fi
Edited by: 876473 on Sep 8, 2011 6:29 AM -
Shell scripts to read data from a text file and to load it into a table
Hi All,
I have a text file consisting of rows and columns as follows,
GEF001 000093625 MKL002510 000001 000000 000000 000000 000000 000000 000001
GEF001 000093625 MKL003604 000001 000000 000000 000000 000000 000000 000001
GEF001 000093625 MKL005675 000001 000000 000000 000000 000000 000000 000001 My requirement is that, i should read the first 3 columns of this file using a shell script and then i have to insert the data into a table consisting of 3 rows in oracle .
the whole application is deployed in unix and that text file comes from mainframe. am working in the unix side of the application and i cant access the data directly from the mainframe. so am required to write a script which reads the data from text file which is placed in certain location and i have to load it to oracle database.
so I can't use SQL * loader.
Please help me something with this...
Thanks in advance.1. Create a dictionary object in Oracle and assign it to the folder where your file resides
2. Write a little procedure which opens the file in the newly created directory object using ULT_FILE and inside the FOR LOOP and do INSERTs to table you want
3. Create a shell script and call that procedure
You can use the post in my Blog for such issues
[Using Oracle UTL_FILE, UTL_SMTP packages and Linux Shell Scripting and Cron utility together|http://kamranagayev.wordpress.com/2009/02/23/using-oracle-utl_file-utl_smtp-packages-and-linux-shell-scripting-and-cron-utility-together-2/]
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com -
Shell Script Resource-Timeout error
Hi!!
I have an issue with the Shell Script Resource, the problem is as follows:
When I created a user in this resource and appears a error message:
com.waveset.util.WavesetException: An error occurred adding user 'user01' to resource 'Shell Script'. com.waveset.util.WavesetException: Script failed waiting for "_,)#+(:" in response "" com.waveset.util.WavesetException: Script processor timed out with nothing to read and the following unprocessed text: "".
I added the timeout property = 300 000 in my shell script is as follows:
<ResTypeAction restype='Shell Script' timeout='300000'>
but it doesn't work.
I had the IDM 8 with the patch 4 but the problem beging when I did upgrade to patch 4 to 6.
Does anyone knows what could be the problem.
Thanks in advance!Hello!
That isn't the problem the test connection works fine but when I try provisioning a user the shell script execute some instructions, in the shell script I need to set the timeout property in order to give more time to finish execute the instructions before the script execute the following command.
I tested the timeout property in the shell script and work to fine for IDM 8 patch 4 I upgrade to patch 10 and stopped to work.
Does anyone knows What could be the rigth way to set the timeout property in a resource action for shell script resource?
Thanks... -
How to use CONCSUB program in shell script program
I have to write a shell script which will further call the concurrent program.
My concurrent program is having 3 parameters. Plz send some suggestion
R's
VijayPl use the search feature to locate threads that have discussed this issue before. Some examples -
Re: modify .out file
Re: shell script using CONCSUB utility
HTH
Srini -
Using rsh within shell script unable to run CONCSUB utility.
I am writing a shell script which will connect to the application server from my DB server.
I am using RSH for the same and it is working. Now I want to submit Active Users Request using CONCSUB but
I am not finding correct syntax for the same.
I am able to execute adstpall.sh using the below combination of commands:
rsh <server> ". <SCRIPT_LOCATION>/adstpall.sh apps/paswd" > /usr/admin/scripts/my_direc
Similarly I want to execute CONCSUB but I am not finding the exact syntax for its execution from rsh.
Thank you very much.Hi,
Thank for the note IDs. But the issue is I am trying to connect to my application server from the DB server using RSH.
After connecting I am starting the application services using adstrtal.sh and post which I intend to do sanity check
by submitting Active Users from backend using CONCSUB utility.
I am getting the below message when trying to do so:
CONCSUB APPS/****** SYSADMIN "System Administrator" SYSADMIN WAIT=Y CONCURRENT FND FNDSCURS PROGRAM_NAME='"Active Users"'
++ CONCSUB APPS/******* SYSADMIN 'System Administrator' SYSADMIN WAIT=Y CONCURRENT FND FNDSCURS 'PROGRAM_NAME="Active Users"'
/oracle/admin/scripts/U_D/abc123/CONCSUB.sh: line 3: CONCSUB: command not found
I am able to execute CONCSUB within a shell script on my application server though (just placing the CONCSUB command within a file and executing it).
CONCSUB APPS/******* SYSADMIN "System Administrator" SYSADMIN WAIT=Y CONCURRENT FND FNDSCURS PROGRAM_NAME='"Active Users"'
+ CONCSUB APPS/******* SYSADMIN 'System Administrator' SYSADMIN WAIT=Y CONCURRENT FND FNDSCURS 'PROGRAM_NAME="Active Users"'
Submitted request 11897805 for CONCURRENT FND FNDSCURS PROGRAM_NAME="Active Users"
Normal completion
========
Please guide.
Thanks,
Farheen Rasul. -
Trouble in Unix calling a Java utility from another shell script
Hi,
I'm able to run a shell script (call it script B) in Unix which calls a Java utility. When I call script B from another script (script A) I get the error below. I have done much work to make sure the environment variables are the same.
java.util.zip.ZipException: error in opening zip f
ile
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:69)
at com.something.runtime.ZipFileApplicationSource.<init>(ZipFileApplicationSource.java:22)
at com.something.runtime.ZipFileRuntime.main(ZipFileRuntime.java:35
ANY HELP WOULD BE GREATLY APPRECIATED.
ThanksHere's my guess, if this doesn't work, post your scripts and maybe that will help.
When you run your script B, you said it works. I think the problem is that when you run script B, your shell and envirenment variables are set by the window you're working in. When you call script B from script A, it creates a new shell to run it and it doesn't run the files that are run when you start a terminal or a telnet(it won't run .cshrc, .kshrc or .login). Depending on what OS you're using, I think the default shell is sh for most of them. The first line of script B should be
#!/(your bin directory)/(shell you're using)
for me it's
#!/bin/tcsh
then you might want to run your startup file to set envirenment variables, paths, etc...
source (your user directory)/(the file name)
for me it's
source ~/.cshrc
Then if you need to set the environment variables in your script.
set CLASSPATH /usr/local/j2ee/bin.....
set PATH /bin:/xyz....
If that doesn't help post your scripts, or if I didn't explain it will enough, just ask. -
Simple shell script utility to copy abs tree for build
Hi,
I'm learning shell script and decided to make a simple script to copy the folder i want from /var/abs to
a new folder so i can build the package. here it is: (remember, i'm new to shell scripting, if you know a better way to do it, you can modify my script
and post here a better solution, so, i (and others) can learn with my errors)
#!/bin/bash
#Looks for the abs tree of the software you want
#and copy it to your build path
ABSTREE=/var/abs
echo -n "What software do you want? "
read absname
result=$(find $ABSTREE -name $absname)
for i in $result; do
echo -n "$i, is this what you want? [y/n] "
read opt
if [ $opt = "y" ]; then
echo -n "Copy to... "
read buildpath
relative=${i#$ABSTREE}
absolute=$buildpath${relative%$absname}
mkdir -p $absolute
cp -r $i $absolute
echo "$i successfully copied to $absolute"
exit 0
fi
done
exit 1spoonman wrote: mkdir -p $absolute
cp -r $i $absolute
echo "$i successfully copied to $absolute"
You are assuming `mkdir` and `cp` were successful. You should test them to make sure, and exit with failure if not:
mkdir -p $absolute || exit 1
cp -r $i $absolute || exit 1
echo "$i successfully copied to $absolute"
You could also include your own error message, but mkdir and cp would throw their own if something fails...
mkdir -p $absolute || { echo "mkdir failed"; exit 1; }
cp -r $i $absolute || { echo "cp failed"; exit 1; }
echo "$i successfully copied to $absolute"
Another way is to use `set -e` which will exit the script on any failure without explicit testing:
set -e
mkdir -p $absolute
cp -r $i $absolute
set +e
echo "$i successfully copied to $absolute" -
How to call a shell script from a java code
Hello can any one suggest me how to call a shell script from a java program that takes three parameters.
i have a shell script (msp_restore_gui) when i run this script in the command line in a RHEL5 ,SUSE10 and Debian machine it works fine .I even tested to call it from a java program and it also worked fine but when i used the same in a J2ee application where the user when clicks the restore button in a webserver this inturn sends the request to a java file named BackupManager.java where i call the shell script.But here it fails.Waiting for your suggestions.If you want i can put the code also hereyes the script is in /usr/local/mss/tools/backup and the script (msp_restore_gui) is as follows
#!/bin/sh
TIMESTAMP=`date +%d_%b_%y-%H-%M`
touch /var/backups/mss/mss_restore_"$TIMESTAMP".log
LOGFILE="/var/backups/mss/mss_restore_"$TIMESTAMP".log"
### Explode tgz file
cd /
# Checks to be done:
# root login
# assume he passes the parameter as msp_backup_<timestamp>
# check for the existence of the .tz and fileList.txt
# Checking for the root login and if not logged on as root
# permission will be denied to execute this script
logmsg(){
echo "`date`: $*" >> $LOGFILE 2>&1
echo "$*"
#usage of this script
while [ $# -ne 0 ]
do
case $1 in
-n)
shift
ARCHIVE_NAME=`find / \( -name "$1.tz" -o -name "$1.tgz" \) 2>/dev/null`
FILE_NAME=`find / -name $1_filesList.txt 2>/dev/null`
if [ x$ARCHIVE_NAME = x -a y$FILE_NAME = y ]
then
logmsg "ERROR: Files not found, Restore cannot proceed"
usage
else
tar tvzf $ARCHIVE_NAME > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "ERROR: The tar file $ARCHIVE_NAME is not proper. Restore cannot proceed"
exit 1
else
echo "Backedup files are present, proceeding with restore......" >> $LOGFILE 2>&1
fi
fi
usage
SKIP_CLEANUP=1
STATUS=1
exit
esac
shift
done
rm -rf ./newfile
curr_ver_file="/usr/local/mss/etc/version"
/usr/local/mss/tools/backup/check_version $curr_ver_file $FILE_NAME
ret_code=$?
echo "Exit value of check_version is $ret_code"
if [ "$ret_code" != 0 ]
then
logmsg "MSP Version not matching. Exiting from restore now...."
errormsg=`cat /usr/local/mss/temp/ver_err_mesg`
logmsg $errormsg
rm -f /usr/local/mss/temp/ver_err_mesg
exit 1
else
echo "Version check is successful"
fi
#### ShutDown MSS########
/etc/init.d/mss stop
sleep 2
### Shutdown semm
/etc/init.d/semm stop
sleep 2
rm -rf `grep -v "MSP Version:" $FILE_NAME`
logmsg "MSP restore in progress......"
tar mxvfz $ARCHIVE_NAME >> $LOGFILE
sleep 5
### Call mysql restore script
/usr/local/mss/bin/mysql_alldb_restore.sh >> $LOGFILE 2>&1
if [ $? -ne 0 ]; then
logmsg "Database restore Failed. Cannot proceed further"
exit 1 ;
else
logmsg "Database restore Succeeded."
fi
### Remove DB Dump Files
rm -f /var/lib/mysql-dumps/*
### Trigger cleanup of airprism database tables
#touch /usr/local/mss/airprism/server/config/reinitdb
### Trigger re-import of software packages
touch /usr/local/mss/swdepot/reimport
### Remove log files under the "apps" directory
find /usr/local/mss/apps -name '*.log*' | xargs rm -f
find /usr/local/mss/logs -follow -name '*[._]log*' | xargs rm -f
if [ $? -ne 0 ]; then
logmsg "MSP restore Failed. Cannot proceed further"
exit 1 ;
else
logmsg "MSP restore Succeeded."
fi
# reinstall_patch is touched so that patches are re-installed after restoring of MSP.
touch /usr/local/mss/patch/bin/reinstall_patch
##### Start MSS
logmsg "restarting MSP server "
/etc/init.d/mss start
sleep 5
### Start semm
/etc/init.d/semm start
sleep 5
logmsg "MSP server is now restarted"
my jsp page backup.jsp is as follows
<%@taglib uri="portlet.tld" prefix="uif" %>
<%@taglib uri="msp-console.tld" prefix="msp" %>
<uif:defineObjects/>
<%@page import="javax.portlet.*" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.Vector" %>
<%@ page import="java.text.DateFormat" %>
<%@ page import="com.symbol.mss.console.admin.backup.BackupManager" %>
<%@ page import="com.symbol.mss.console.admin.system.SystemInfoPortlet" %>
<%
String STYLE_NAME = request.getParameter("style");
if (STYLE_NAME == null) STYLE_NAME = STYLE_DEFAULT;
final String ua = request.getHeader("User-Agent");
BackupManager helper = null;
PortletSession portletSession = renderRequest.getPortletSession();
helper = (BackupManager)portletSession.getAttribute("helper");
if (helper == null) {
//System.err.println("Created new BackupManager");
helper = new BackupManager();
portletSession.setAttribute("helper", helper);
final BackupManager backupManager = helper;
String action = "";
final String backupName = renderRequest.getParameter("backupName");
String completePath = backupManager.getBackupDir() + backupName + backupManager.getBackupFileExt();
if (backupName != null) {
action = "backup";
if(backupManager.backup(backupName)) {
SystemInfoPortlet.beginRestartMSP();
} else {
action = "backuperror";
final String cmd = renderRequest.getParameter("submitButton");
final String selectedBackup = renderRequest.getParameter("selectedBackup");
int tarFileStatus =0;
String backupTarFile ="";
String backupFileList ="";
if ("Restore".equals(cmd)) {
if (selectedBackup != null) {
tarFileStatus = backupManager.verifyTarFile(selectedBackup);
//backupTarFile = backupManager.getRestoreFile(Integer.parseInt(selectedBackup));
//backupFileList = backupTarFile.substring(0, backupTarFile.lastIndexOf(backupManager.getBackupFileExt()))+"_filesList.txt";
if (tarFileStatus == 0){
action = "restore";
backupManager.restore(selectedBackup);
SystemInfoPortlet.beginRestartMSP();
} else {
action = "error";
} else if ("Remove".equals(cmd)) {
backupManager.remove(Integer.parseInt(selectedBackup));
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
PortletURL restoreURL = renderResponse.createActionURL();
%>
<%@ include file="/jsp/core/constants.jspf" %>
<% if (action.length() > 0) {
if ("backup".equals(action))
%>
<p>The MSP Appliance has been shut down in order to create the <%=backupName %> backup file,
and will automatically restart as soon as the file has been created.
To continue your work, please log out of the MSP Console, wait for the appliance
to restart, and then log back in. The amount of time you'll have to wait for the
MSP Appliance to come back online depends on the amount of information you have
stored in the MSP Database.</p>
<p>The full pathname for the backup file is: <%=completePath %></p>
<% }
else if ("restore".equals(action))
%>
<p>The MSP Appliance has been shut down in order to restore from the <%=backupTarFile%> backup file,
and will automatically restart as soon as the restore is complete.
To continue your work, please log out of the MSP Console, wait for the appliance
to restart, and then log back in. The amount of time you'll have to wait for the
MSP Appliance to come back online depends on the amount of information you have
stored in the MSP Database.</p>
<% } else if ("backuperror".equals(action)) { %>
<p><img src="images/dialogue/error_16.gif" class="icon" alt="Notify" /> Errors occurred while taking back up of MSP. Please see the backup service log file for more details.
</P>
<% } else if ("error".equals(action)) {
if (tarFileStatus == 4) { %>
<p><img src="images/dialogue/error_16.gif" class="icon" alt="Notify" /> The backup file <%=backupTarFile%> contains errors. This backup can't be restored. Please restore a valid back up.
</P>
<%} else if (tarFileStatus == 3) { %>
<p><img src="images/dialogue/error_16.gif" class="icon" alt="Notify" /> The backup file list <%=backupFileList %> is missing. This file is required to restoring backup. Please get the backup file list and proceed with restoring backup.</p>
<%} else if (tarFileStatus == 2) { %>
<p> <img src="images/dialogue/error_16.gif" class="icon" alt="Notify" /> The backup file <%=backupTarFile%> contains errors and the backup file list <%=backupFileList%> is missing. This backup can't be restored. </p>
<%} %>
<% }
} else { %>
<p><strong>Note</strong>: Both backup and restore will shut down MSP temporarily. MSP will be unable to collect data from devices, send notifications, or provide MSP Console access during this time. When the backup or restore operation is complete, MSP will come back online automatically.</p>
<h3>Backup</h3>
<form action="<%= restoreURL.toString() %>" method="post">
<p>Please provide a name for your backup. MSP will provide the date automatically in the list of backups.</p>
<p><label for="<uif:namespace />backupName">Name</label> <input type="text" name="<uif:namespace />backupName" id="<uif:namespace />backupName" size="20" maxlength="256" /> <input type="submit" name="<uif:namespace />submitButton" value="Back up now" onclick="return <uif:namespace/>validateName()"/></p>
</form>
<h3>Restore</h3>
<p>This will restore all databases (device assets, collected device data, software packages, policies, etc.) to their state as of the time the backup was made. Changes since then <em>except for backups</em> will be destroyed.</p>
<%
Vector restoreList = helper.getRestoreEntries();
Vector restoreDates = helper.getRestoreDates();
Vector restoreVersions = helper.getRestoreVersions();
Vector filesStatus = helper.getBackupFilesStatus();
%>
<% if (restoreList.size() == 0) { %>
<p>There are no backups currently available.</p>
<% } else { %>
<form action="<%= restoreURL.toString() %>" method="post">
<table class="input-radios" id="<uif:namespace />existingBackups">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Date</th>
<th>MSP Version</th>
<th>Remarks </th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4" class="actionsOnSelected">
<input type="submit" name="<uif:namespace />submitButton" value="Restore" onclick="return confirm('This action requires MSP and all related services to be shut down. Console will be unavailable if the request is submitted. The server will restart automatically once restore has been completed.');" />
<input type="submit" name="<uif:namespace />submitButton" value="Remove" onclick="return confirm('This action will remove the backup archive. You will no longer be able to restore this backup. Continue?');" />
</td>
</tr>
</tfoot>
<tbody><%-- First one (most recent) is checked by default. Every other row has class="portlet-section-alternate". Note that each ID must be unique and must match the value of the "for" attribute on the corresponding "label" element. --%>
<%
for (int i = 0; i < restoreList.size(); i++) {
%>
<tr <%= (i % 2 == 1) ? " class=\"portlet-section-alternate\"" : "" %>>
<td><input type="radio" name="<uif:namespace />selectedBackup" value="<%= i %>" id="<uif:namespace />selectedBackup-<%= i %>" <%= (i == 0) ? "checked=\"checked\"" : "" %> /></td>
<td><label for="<uif:namespace />selectedBackup-<%= i %>"><%= restoreList.elementAt(i) %></label></td>
<td><%= dateFormat.format((Date)restoreDates.elementAt(i)) %></td>
<td><%= restoreVersions.elementAt(i) %></td>
<td><%= filesStatus.elementAt(i) %></td>
</tr>
<%
%>
</tbody>
</table>
</form>
<% } %>
<% } %>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
function <uif:namespace/>validateName() {
var name =document.getElementById("<uif:namespace />backupName");
var msg= "<msp:i18n key="BackupMsg"/>";
var str=name.value;
var re = /^[A-Za-z0-9_]+$/;
if (!str.match(re)) {
alert(msg);
name.focus();
return false;
} else {
return confirm('This action requires MSP and all related services to be shutdown. Console will be unavailable if the request is submitted. The server will restart automatically once backup has been completed.');
//--><!]]>
</script>
and my BackupManager.java is as follows where the code in bold and italic is called the restore()
//============================================================================
// Symbol Technologies P R O P R I E T A R Y S O U R C E C O D E
// C O N F I D E N T I A L
// Copyright (c) 2003 Symbol Technologies. All Rights Reserved.
// All information contained herein is the property of Symbol Technologies,
// or its Licensors, and are protected copyrights and trade secrets, and may
// be covered by U.S. patents. Any reproduction or dissemination of any
// portion of this document, of the software, or other works derived from it
// is strictly forbidden unless prior written permission is obtained from
// Symbol Technologies.
//============================================================================
package com.symbol.mss.sdf.services.backup;
import java.io.*;
import java.sql.Time;
import java.text.DateFormat;
import java.util.logging.FileHandler;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import java.lang.Process;
import java.util.*;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
import com.symbol.mss.sdf.admin.AdministratorService;
import com.symbol.mss.sdf.backup.*;
import com.symbol.mss.sdf.data.*;
* @author nramaiah
* Service to perform scheduled backups of the system state.
public class BackupManager implements BackupService, DataHandler,
LogEnabled, Configurable {
// MSS Home Path
private static String mssHome = System.getProperty("phoenix.home", File.separator + "usr" +
File.separator + "local" +
File.separator + "mss" +
File.separator);
// Backup related definitions
private static final String BACKUP_LIST_FILE_NAME = "conf" + File.separator + "files_to_backup.txt";
private static final String BACKED_UP_LIST_FILE_NAME_SUFFIX = "_filesList.txt";
private static final String BACKUP_LOCATION = File.separator + "var" + File.separator + "lib" +
File.separator + "mss-backups" + File.separator;
private static final String BACKUP_PARTITION = File.separator + "var" + File.separator + "lib";
private static final String VERIFY_BACKUP = File.separator + "usr" + File.separator + "local" +
File.separator + "mss" + File.separator+"tools"+
File.separator+"backup"+File.separator+"verifyBackup.sh";
// DB backup/restore related definitions
private static final String DB_DUMP_LOCATION = File.separator + "var" + File.separator +
"lib" + File.separator +
"mysql-dumps" + File.separator;
private static final String DB_BACKUP_SCRIPT = "bin" + File.separator + "mysql_alldb_backup.sh";
private static final String DB_RESTORE_SCRIPT = "bin" + File.separator + "mysql_alldb_restore.sh";
// Private variables
private AdministratorService m_admin = null;
private Logger m_logger = null;
private String backupLocation = null;
private String backupListFileName = null;
private String backupPartition = null;
private int backupPartitionLimit = 90;
private String dbDumpLocation = null;
private String dbBackupScript = null;
private String dbRestoreScript = null;
private List servicesBackupList = null;
private String tarFileExtension =".tgz";
private String errFileExtension =".err";
private int exitValue=0;
* Default Constructor
public BackupManager() {
servicesBackupList = new ArrayList();
* Set the administrator service implementation. Link established by Broker service.
* @param admin reference to an implementation of AdministratorService
public void setAdministrator(AdministratorService admin) {
m_admin = admin;
* Set the job publisher service implementation. Link established by Broker service.
* @param jobPublisher reference to an implementation of JobPublisherService
public void setJobPublisher(DataChannel jobPublisher) {
jobPublisher.subscribe(this);
* Gets the backup manager object.
* @return backup manager object
public BackupService getBackupService() {
return this;
* Service lifecycle method.
* @param logger logger object to be used by the service
public void enableLogging(Logger logger) {
m_logger = logger;
* Service lifecycle method.
* @param configuration service configuration object
public void configure(Configuration configuration) throws ConfigurationException {
// Verify MSS Home path
if (!mssHome.endsWith(File.separator))
mssHome += File.separator;
// Get the location where the backup file needs to be placed
backupLocation = configuration.getChild("BackupLocation").getValue(BACKUP_LOCATION);
// Verify backup directory path
if (!backupLocation.startsWith(File.separator))
backupLocation = mssHome + backupLocation;
if (!backupLocation.endsWith(File.separator))
backupLocation += File.separator;
// Get the file listing the files/directories to be backed up
backupListFileName = configuration.getChild("FilesList").getValue(BACKUP_LIST_FILE_NAME);
// Verify backup list file name path
if (!backupListFileName.startsWith(File.separator))
backupListFileName = mssHome + backupListFileName;
// Get the partition where the backups are kept
backupPartition = configuration.getChild("BackupPartition").getValue(BACKUP_PARTITION);
// Verify backup partition path
if (!backupPartition.startsWith(File.separator))
backupPartition = File.separator + backupPartition;
if (backupPartition.endsWith(File.separator))
backupPartition = backupPartition.substring(0, (backupPartition.length()-1));
// Get the limit on the amount of free space on the backup partition
backupPartitionLimit = configuration.getChild("BackupPartitionLimit").getValueAsInteger(backupPartitionLimit);
// Get the location where the DB dump files will be placed
dbDumpLocation = configuration.getChild("DBDumpLocation").getValue(DB_DUMP_LOCATION);
// Verify DB dump directory path
if (!dbDumpLocation.startsWith(File.separator))
dbDumpLocation = mssHome + dbDumpLocation;
if (!dbDumpLocation.endsWith(File.separator))
dbDumpLocation += File.separator;
// Get the name of DB dump backup script
dbBackupScript = configuration.getChild("DBBackupScript").getValue(DB_BACKUP_SCRIPT);
// Verify backup script path
if (!dbBackupScript.startsWith(File.separator))
dbBackupScript = mssHome + dbBackupScript;
// Get the name of DB dump restore script
dbRestoreScript = configuration.getChild("DBRestoreScript").getValue(DB_RESTORE_SCRIPT);
// Verify restore script path
if (!dbRestoreScript.startsWith(File.separator))
dbRestoreScript = mssHome + dbRestoreScript;
* Individual services can supply a list of files/directories to be backed up.
* These are files apart from the files specified in conf/files_to_backup.txt and
* will be backed up as well.
* @param files list of files/directories
public void filesToBackup(List files) {
synchronized(this) {
if (files != null) {
if (files.size() > 0) {
// Add the list contents to the current backup list
for (int i=0; i<files.size(); i++) {
String tStr = (String)files.get(i);
// Check for absolute or relative path
if (tStr.startsWith(File.separator))
servicesBackupList.add(tStr);
else
servicesBackupList.add(mssHome + tStr);
else
m_logger.info("Empty list of filenames. Nothing added.");
else
m_logger.info("Null list of filenames. Nothing added.");
* Individual services can supply a list of files/directories to be backed up.
* Specified files will be added to the file defining the list of files to be backed up.
* @param files list of files/directories
private void persistFilesToBackup(List files) {
synchronized(this) {
if (files != null) {
if (files.size() > 0) {
// Add the list of files provided to the end of file
try {
File file = new File(backupListFileName);
if ((file == null) || (!file.exists()))
file.createNewFile();
// Seek to the end of the file
RandomAccessFile rFile = new RandomAccessFile(file, "rw");
if (rFile != null) {
rFile.seek(rFile.length());
// Write the list contents to the file
for (int i=0; i<files.size(); i++) {
String tStr = (String)files.get(i);
// Check for absolute or relative path
if (tStr.startsWith(File.separator))
rFile.writeBytes(tStr + "\n");
else
rFile.writeBytes(mssHome + tStr + "\n");
else
m_logger.error("Error opening file " + backupListFileName);
rFile.close();
catch (Exception ex) {
ex.printStackTrace();
m_logger.error("Error adding entries to file " + backupListFileName, ex);
else
m_logger.info("Empty list of filenames. Nothing added.");
else
m_logger.info("Null list of filenames. Nothing added.");
* Command to be run during the backup process. Individual services can
* provide shell commands that will be executed before backing up the files.
* @param command shell command to be executed
private void runCommand(String command) {
* Creates a shell script at the specified location that will backup the
* files listed in the List passed in.
* @param scriptFileName location where the script needs to be created
* @param backupFileName name for the tar file being created
* @param backupList list of files to be backed up
private void createBackupScript(String scriptFileName, String backupFileName, ArrayList backupList) throws Exception {
// Create a new StringBuffer to build the contents to be written to the script file
StringBuffer buffer = new StringBuffer();
// Add the initial comment in the start script
buffer.append("#!/bin/sh\n" + "set -x\n\n");
// Check if the partition has enough space
buffer.append("### Check if the partition has enough space\n" +
// "diskUsed=`df -k | grep \"" + backupPartition + "\" | awk '{print $5}' | cut -d\"%\" -f1`\n" +
" diskUsed=`df -k \"" + backupPartition + "\" | awk '{print $5}' | cut -d\"%\" -f1 | grep -v Use`\n" +
"echo \"Partition " + backupPartition + " is $diskUsed% used.\"\n" +
"if [ \"$diskUsed\" -lt \"" + backupPartitionLimit + "\" ]\nthen\n" +
" echo \"Starting backup...\"\n\n");
// Shutdown semmd
buffer.append(" ### Shutdown semm\n" + " /etc/init.d/semm stop\n" +
" sleep 2\n\n");
// MSP Limited release and earlier builds stop mysql DB and backup the
// /var/lib/mysql directory as it is. Starting MSP 1.0 GA release, mysql
// dump script will be integrated which will create sql scripts to
// restore the database.
// Check if mysql dump creation script exists
File mysqlDumpScript = new File(dbBackupScript);
if (mysqlDumpScript.exists()) {
// MSP 1.0 GA and later releases
// Run the script that will generate sql scripts that would re-create the DB as it is
buffer.append(" ### Call mysql dump script\n" +
" " + dbBackupScript + "\n\n");
else {
// MSP Limited release
// Add command to shutdown mysql
buffer.append(" ### Shutdown mysql\n" + " /etc/init.d/mysql stop\n\n");
// Change to root directory and create the tgz file
buffer.append(" ### Create tgz file\n" + " cd /\n");
// Build up the tar file name from the current date and time
String fileName = null;
if ((backupFileName != null) && (backupFileName.length() > 0))
fileName = backupFileName;
else {
// File name not provided by user, build one using the timestamp
Calendar cal = Calendar.getInstance();
Date date = cal.getTime();
fileName = "MSS-"
+ DateFormat.getDateInstance().format(date).replaceAll(" ", "").replaceAll(",", "")+ "-"
+ (new Time(cal.getTimeInMillis())).toString().replaceAll(":", "").substring(0,4);
String tarFileName = fileName + ".tgz";
// Get the current MSP Version
String mspVersion = getMSPVersion();
// Gather all the files to be backed up. Add them to the tar command and
// also dump them into the file maintaining the list of files being backed up
String listStr = "";
for (int i=0; i<backupList.size(); i++)
listStr += (String)backupList.get(i) + "\n";
// Dump the current MSP version and the list of files being backed up into a manifest file
String listFileName = fileName + BACKED_UP_LIST_FILE_NAME_SUFFIX;
RandomAccessFile file = new RandomAccessFile(backupLocation + listFileName, "rw");
m_logger.info("List of files/directories being backed up:\n" + listStr);
file.writeBytes("### MSP Version: " + mspVersion + " ###\n");
file.writeBytes(listStr);
file.close();
// Add the tar command to the script
buffer.append(" echo \"Creating " + backupLocation + tarFileName + "...\"\n" +
" tar cvhfz " + backupLocation + tarFileName + " `grep -v \"MSP Version:\" " +
backupLocation + listFileName + "`\n\n");
// Check if free space on the backup partition has reduced below the limit
// If enough space left, backup is retained, "mss" is made the owner of the files,
// "backup" is made the group the files belong to,
// permissions changed to be "0660" and
// backup action declared a success
// Else, backup files are deleted and declared a failure
buffer.append(" ### Check if the partition has enough space left\n" +
//" diskLeft=`df -k | grep \"" + backupPartition + "\" | awk '{print $5}' | cut -d\"%\" -f1`\n" +
" diskLeft=`df -k \"" + backupPartition + "\" | awk '{print $5}' | cut -d\"%\" -f1 | grep -v Use`\n" +
" echo \"Partition " + backupPartition + " is $diskLeft% used.\"\n" +
" if [ \"$diskLeft\" -gt \"" + backupPartitionLimit + "\" ]\n" +
" then\n" +
" ### Failure\n" +
" echo \"Partition " + backupPartition + " does not have enough space.\"\n" +
" echo \"Backup " + backupLocation + tarFileName + " will be removed.\"\n" +
" rm -f " + backupLocation + fileName + "*\n" +
" echo \"Backup Failed.\"\n" +
" else\n" +
" tar tvzf " + backupLocation + tarFileName + " > /dev/null 2>&1\n" +
" if [ ! -s " + backupLocation + tarFileName + " -o $? -ne 0 ] \n" +
" then\n" +
" echo \"MSP Backup operation is not successful. The tar file " + backupLocation + tarFileName + " contains errors.\"\n" +
" echo \"Please take the backup again\"\n" +
" touch "+backupLocation+fileName+".err\n" +
" else \n" +
" ### Success\n" +
" ### Change the owner, group and permissions for the backup files\n" +
" chown mss " + backupLocation + fileName + "*\n" +
" chgrp backup " + backupLocation + fileName + "*\n" +
" chmod 0660 " + backupLocation + fileName + "*\n" +
" echo \"Backup Completed.\"\n" +
" fi\n" +
" fi\n\n");
// MSP Limited release and earlier builds re-start mysql. Starting
// MSP 1.0 GA release, mysql is not stopped and so re-start is not
// needed. sql scripts created by the dump script get packed into
// the tar file and so are deleted.
// Check if mysql dump creation script exists
if (mysqlDumpScript.exists()) {
// MSP 1.0 GA and later releases
// Remove DB dump files
buffer.append(" ### Remove DB Dump Files\n" + " rm -f " + dbDumpLocation + "*\n\n");
else {
// MSP Limited release
// Start mysql
buffer.append(" ### Start mysql\n" + " /etc/init -
How to call a shell script via ODI
Hi,
I need suggestion on following issues:
1) How to call a shell script via ODI?.. I tried using OSCommand utility .inspite of the execution being successful the data is not written into the new file in the desired format. After processing new file is created in the mentioned location but its empty.
2) I'm calling a procedure in ODI to load data into my fact. But once the fact gets loaded i want to update the log details (num of rows processed,num of rows inserted,num of rows rejected etc) in my log table. I'm planning to use a proc for updating but need to know from where can i find these details. Is there a table in work rep which gives me these info like how we get if we execute an interface.?
Please help me out.. Its urgent
Regards
SurabhiHello,
Question 1 appears a little vague, please elaborate. If you're looking to capture a return value from the command execution, you will need to pipe the return value to a file, then read from there.
The execution information is stored in the SNP_STEP_LOG table in the Work Repository. You will need to do a series of joins to retrieve the exact table that was updated. Good luck with this... -
Error while submitting a conc program through CONCSUB in shell script
Hi All,
I am working on 11.5.10.2.
I have a shell script from which I am calling a concurrent program using CONCSUB utility as below
CONCSUB $p_login $p_resp_appl_short_name "$p_resp_name" $p_user_name CONCURRENT $p_conc_appl_short_name $p_conc_prog_name "ABC" $v_seq_num
There are two types of error I am getting:
1. When I am submitting it from Order Management Super User it is giving error
Please enter a valid responsibility. The responsibility Order Management Super User does not exist or is not active. Check that the correct application short name is specified for your responsibility.
2. When I am submitting it from some custom responsibility I am getting following error
Cannot submit concurrent request for program APPS/APPS0
Check if the concurrent program is registered with Application Object Library.
Check if you specified the correct application short name for your concurrent program.
Cannot submit your concurrent request
Please suggest me the possible cause of the error.
Thanks
VishalakshaIt is solved now. In the script I had p_data_file_path=$10 instead of p_conc_prog_name=${10}. This is the reason I was not getting the right concurrent program name as input parameter.
Thanks
Vishalaksha -
Executing a shell script from a web deployed form
Hi there,
i've got a web deployed form from which i want to execute a UNIX shell script upon clicking a button.. I've used the host command ,and the rsh utility in Windows NT but i'm getting an error message saying
"machine address" Permission denied, rsh can't establish connection " this is the code in the when button pressed trigger
HOST('c:\windows\system32\rsh <<machine address>> opt/apps/wmc/rw.ksh');
the machine address being the unix machine i'm trying to connect to and the last part being the path and the shell script to be executed..
can anybody help me out here ????
Regards
wole
nullJim,
Yes. Use the host command from forms and call the command rexec.
Raymond
null -
Error Using dbms_scheduler to call a shell script
Hi,
I have been assigned a job of sending emails through unix utility(Mailx), based on certain activity in database.
Email needs to be sent on insert/update of a column in one of the database tables.
I am trying to use the block below to call the unix script responsible to send mails:
begin
dbms_scheduler.create_job
job_name => 'TPP_SEND_EMAIL_JOB',
job_type => 'EXECUTABLE',
job_action => '/opt/ENV/code/BIL/users/usrbil01/Hemz/sndmailscrpt.ksh',
repeat_interval => 'FREQ=MINUTELY; INTERVAL=30',
enabled => true,
comments => 'Send Email on ISU update'
end;
sndmailscrpt.ksh: Script to send email is embedded within the shell script
I am getting the below error when i try to run the job using 'exec dbms_scheduler.run_job('TPP_SEND_EMAIL_JOB');'
Error:
ORA-27370: job slave failed to launch a job of type EXECUTABLE
ORA-27300: OS system dependent operation:accessing extjob wrapper failed with status: 2
ORA-27301: OS failure message: No such file or directory
ORA-27302: failure occurred at: sjsec 3
ORA-06512: at "SYS.DBMS_ISCHED", line 150
ORA-06512: at "SYS.DBMS_SCHEDULER", line 441
ORA-06512: at line 1
I am not aware of any db related permissions that needs to be given, is this related to that or is there somethin i need to do for execution to be successfull
Request you to let me know the exact solution and also the steps i need to take in order to ensure successfull execution of this script.
Please also let me know if there is any other way wherein i can call a unix script from a database trigger on run time(i.e, whenever insert/update on a particular column in database)
Regards,
HemanthHi All,
Thank you for your inputs.
I am now pressed to explore the option of utl_mail as this dircetly sends mail from database. This is suggested as an option for my delivery now.
I am able to install utl_mail and send a mail using the block below:
begin
utl_mail.send(
sender => '[email protected]',
recipients => '[email protected]',
subject => 'Testing utl_mail',
message => 'The receipt of this email is checking on working of UTL_MAIL '
exception
when others then
dbms_output.put_line('error: '||sqlerrm);
end;
The block gets executed successfully, but i have not received a mail yet, is there a table or oracle log from where i can trace the delivery status for the mai, or if the mail is successfully sent too?
I have heard from users in this forum for support of mime type "HTML", Should i pass the whole html body in the *'message'* input parameter here or can i pass a html template name with path present else where?
Please do assist me in this regard.
Regards,
Hemanth
Maybe you are looking for
-
Hello! I do have an urgent problem. I was working on an imovie-project. Imovie asked to create thumbnails - after that I no longer see this project in iMovie - other projects are still there. The funny thing is, that the file is still in the library
-
Hi all. We have configure a JDI server. But when we are using NWDS to connect that server, and create a new DC, it returns us the error. Invalid name; on this server no name of category SAP_DevelopmentComponentName are allowed at all. Whats the probl
-
Hi, I am having the same problem as other people on here about getting pictures out of the Adobe 3.2 after the sunscription ran out. Of course I can't register and unlock it because it is no longer supported. I tried this a couple of years ago and te
-
Yes, I am changing religions! My Mac Pro arrives this week and all my video and graphics will be done on the Mac in the future. Here is my question. What is the right way to move my image files and the Lightroom database info from the PC to the Mac.
-
Hey experts. I'm hoping you can help me out or at least give me some general direction. We're getting together some family to discuss some family history/memories and I want to record the conversation. I have two microphones that aren't great but wil