Call script from script; exit code issues
I have verified in a very simple pair of scripts that I can feed an exit code back to the calling script. My "Parent" test is little more than
powershell.exe -file "$ScriptPath\child.ps1"
Write-Host "$LASTEXITCODE!!!"
and the child script is just
Exit 1
And that Write-host comes back correctly. I have even tried it with two different child scripts, with different rerun codes, being called from Parent back to back. All good.
However, in a more complicated script, where the child script has conditional exits, I am getting 0 all the time. The conditional looks like this
if ($Global:MemberofSet) {
if ($Global:ErrorOccured) {
Write-Host '1'
Exit 1
else {
Write-Host '0'
Exit 0
And even when the 1 echoes, I still get a $LASTEXITCODE of 0.
Is there some known issue here that I am not aware of? Using PS 2.0, FWIW.
Thanks!
Um, no, more that I remmed out
[CmdletBinding()] at the top of each child script and with no other changes everything is working exactly as it should. Not sure why it worked, but I am certainly not imagining it.
For shits and giggles I also added the binding in my little test script set, and that is now broken,
with no other changes. I really hadn't created a good test obviously, but I wasn't expecting binding to matter. Would love to hear an explanation as to why it would
For anyone wanting to see the behavior, these are the three test scripts, and you run the Arch script. With binding enabled DTV will show 1, but return 0. Rem the
bindings and DTV will correctly return 1. I also tested RVT to not be MemberofSet, so -1 is returned, and $LASTEXITCODE shows a wonky number as expected given the bug in 2.0 and negative return codes.
NOTE: In the test the argument in the child scripts is not used, it's just there to avoid the error you otherwise get when binding. In my "live" code the
arguments are mandatory and used.
Arch_2015.ps1
powershell.exe -file "RVT_2015.ps1"
Write-Host "$LASTEXITCODE!"
powershell.exe -file "DTV_2015.ps1"
Write-Host "$LASTEXITCODE!"
DTV_2015.ps1
[CmdletBinding()]
Param ([string]$Mode)
$Global:MemberofSet = $True
$Global:ErrorOccured = $True
if ($Global:MemberofSet) {
if ($Global:ErrorOccured) {
Write-Host 'DTV 1'
Exit 1
else {
Write-Host 'DTV 0'
Exit 0
else {
Write-Host 'RVT -1'
Exit -1
RVT_2015.ps1
[CmdletBinding()]
Param ([string]$Mode)
$Global:MemberofSet = $True
$Global:ErrorOccured = $False
if ($Global:MemberofSet) {
if ($Global:ErrorOccured) {
Write-Host 'RVT 1'
Exit 1
else {
Write-Host 'RVT 0'
Exit 0
else {
Write-Host 'RVT -1'
Exit -1
Similar Messages
-
Error while executing UNIX script from BODS - exit code 127
I am trying to execute a unix script by calling it in BODS job. It is giving an error saying Program terminated with exit code 127. The same script when i am executing in UNIX it is working fine. I am unable to trace the issue.
Hi Sabre,
As per the guidelines provided by the article, i had done below changes..
InputStream is = null;
InputStreamReader iStreamReader = null;
BufferedReader bReader = null;
String line = null;
try{
String fileName ="test.ksh";
String argValue ="satish"; // value passed to the script
String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
Process proc = Runtime.getRuntime().exec(exeParam);
is = proc.getErrorStream();
iStreamReader = new InputStreamReader(is);
bReader = new BufferedReader(iStreamReader);
System.out.println("<ERROR>");
while((line = bReader.readLine()) != null)
System.out.println("Error is : "+line);
System.out.println("</ERROR>");
int exitValue = proc.waitFor();
sop("Exit Value is : "+exitValue);
catch(Exception e)
e.printStackTrace();
Now , it's showing something like..
<ERROR>
</ERROR> -
Troubleshooting PostPrepare script failed with exit code 1
i get a 'PostPrepare' script failed with exit code '1' message on one of the bundles, and i think i am missing some obvious thing
it is a simple file bundle, to distribute a pdf printer:
it distributes 2 files:
ADIST.PPD to /usr/share/cups/model
pdf-printer to /usr/lib/cups/backend
(script based upon Cool Solutions: A CUPS PDF Printer for your SUSE Linux Enterprise Desktop
then it should execute a pre-installation script that executes:
Code:
#!/bin/bash
rccups restart
mkdir -p /export/share/pdf
chmod -R 777 /export
lpadmin -p Desktop-PDF -v pdf-writer:/export/share/pdf/ -E -P /usr/share/cups/model/ADIST5.PPD -D "PDF Writer for CUPS" -L "PDF on desktop"
manually placing the files on these locations and executing the script works fine
on the machine i get (device set to log debug and above)
Code:
22 Jul 2010 09:33:00 INFO BundleManager Executing preprepare scripts for PDF printer
22 Jul 2010 09:33:00 DEBUG Progress Is Stopped value: False
22 Jul 2010 09:33:00 INFO WebCache Attempting to retrieve 'https://zlmserver/zenworks-pkgmgt/repo/getBundleFile/3ba56c5bc95bb2874273a7d0cae07d14/8/sled-11-i586/ADIST5.PPD' (try 1)
22 Jul 2010 09:33:01 INFO WebCache Successfully retrieved https://zlmserver/zenworks-pkgmgt/repo/getBundleFile/3ba56c5bc95bb2874273a7d0cae07d14/8/sled-11-i586/ADIST5.PPD
22 Jul 2010 09:33:01 DEBUG Progress Is Stopped value: False
22 Jul 2010 09:33:01 INFO WebCache Attempting to retrieve 'https://zlmserver/zenworks-pkgmgt/repo/getBundleFile/3ba56c5bc95bb2874273a7d0cae07d14/8/sled-11-i586/pdf-writer' (try 1)
22 Jul 2010 09:33:01 INFO WebCache Successfully retrieved https://zlmserver/zenworks-pkgmgt/repo/getBundleFile/3ba56c5bc95bb2874273a7d0cae07d14/8/sled-11-i586/pdf-writer
22 Jul 2010 09:33:01 DEBUG Progress Is Stopped value: False
22 Jul 2010 09:33:01 DEBUG Progress Is Stopped value: False
22 Jul 2010 09:33:01 INFO BundleManager Executing postprepare scripts for PDF printer
22 Jul 2010 09:33:01 DEBUG Progress Is Stopped value: False
22 Jul 2010 09:33:01 INFO BundleManager Successfully prepared bundles
22 Jul 2010 09:33:01 INFO BundleManager Beginning bundle transaction
22 Jul 2010 09:33:01 INFO BundleTransaction Beginning bundle transaction: 1 installs, 0 removals.
22 Jul 2010 09:33:01 INFO BundleTransaction Executing preinstall scripts for PDF printer
22 Jul 2010 09:33:01 INFO SystemCatalog Saving system catalog containing 9 bundles
22 Jul 2010 09:33:01 ERROR BundleTransaction Novell.Zenworks.Zmd.BUNDLE_INSTALL_ERROR: Novell.Zenworks.Zmd.BUNDLE_INSTALL_ERROR
Novell.Zenworks.Zmd.Public.ZenException: 'PreInstall' script failed with exit code '1'
22 Jul 2010 09:33:01 INFO Progress Progress.Stop Message: Bundle transaction failed: 'PreInstall' script failed with exit code '1'
22 Jul 2010 09:33:01 DEBUG Progress Is Stopped value: False
22 Jul 2010 09:33:01 ERROR BundleManager Transaction failed: Bundle transaction failed: 'PreInstall' script failed with exit code '1'
22 Jul 2010 09:33:01 INFO Progress Progress.Stop Message: Parent failed/aborted
22 Jul 2010 09:33:01 DEBUG Progress Is Stopped value: False
22 Jul 2010 09:33:01 INFO Progress Progress.Stop Message: Parent failed/aborted
22 Jul 2010 09:33:01 DEBUG Progress Is Stopped value: False
22 Jul 2010 09:33:01 INFO Progress Progress.Stop Message: Parent failed/aborted
22 Jul 2010 09:33:01 DEBUG Progress Is Stopped value: False
22 Jul 2010 09:33:01 INFO Progress Progress.Stop Message: Parent failed/aborted
22 Jul 2010 09:33:01 DEBUG Progress Is Stopped value: False
22 Jul 2010 09:33:01 ERROR ActionManager Failed to execute scheduled action (install (bundles=3ba56c5bc95bb2874273a7d0cae07d14)): Bundle transaction failed: Bundle transaction failed: 'PreInstall' script failed with exit code '1'
Novell.Zenworks.Zmd.Public.ZenException: Bundle transaction failed: Bundle transaction failed: 'PreInstall' script failed with exit code '1'
22 Jul 2010 09:33:01 INFO BundleTransaction Bundle transaction ended.
clients: sled11sp1 i586
server: sles11 x64 + zlm732
the files are not copied to their destination
the target directories are available, writable by root (obviously) there are no files with the same name available, adding a trailing slash to the target path does not help (but other bundles have no trailing slash and run ok)
questions:
where are the temporary files copied to?
where/how can i find what might be causing the preinstall error?
should i delete previous versions of the bundle in zlmuntil you delete the previous version in zlm and do a rug ref... or is this as designed
When you make changes to the bundle you need to apply them. That creates a new version and then you need to deploy that new version. Apply and deploy are on the same page. But I guess you know that.
If you already did that and still had problems, it might be the zen loader that needs a little bit more time. Once you hit deploy, a zen queue entry gets created that informs the zen loader to update the bundle xml file in the file repository. That file is delivered to the managed device when it queries for bundle information. So if that bundle xml contains the old version, the client will see that.
Problems here can be that the zen loader simply needs a few seconds longer then when you change to the device and run rug ref. Or there can be other queue entries that get processed and the bundle xml update is just in the queue and waiting. The zen loader has 5 slots for processing queue entries.
On the zlm server you can run "zlman ql I" for in progress entries and "zlman ql N" for new state entries that ned to be processed.
Or you can use the short script I posted (Cool Solutions: Monitor ZLM queue entries with Nagios) that shows you in one line how many and what type of queue entries currently exist. This is what I always use to get a overview about the queue status.
Rainer -
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 -
Calling Unix shell script from PL/sql code
Hi
I need to call a shell script from a procdeure which i need to run in toad. Let me kno whow can i do that and connect to unix box with an example.Thanks Avinash,
That on was very useful.
When I try to execute I got the following error.
Could you let me now What privileges are required?
SQL> BEGIN
dbms_scheduler.create_job(job_name => 'myjob',
job_type => 'executable',
job_action => '/home/rananto/a.sh',
enabled => TRUE,
auto_drop => TRUE);
END;
/ 2 3 4 5 6 7 8
BEGIN
ERROR at line 1:
ORA-27486: insufficient privileges
ORA-06512: at "SYS.DBMS_ISCHED", line 99
ORA-06512: at "SYS.DBMS_SCHEDULER", line 262
ORA-06512: at line 2
SQL> exec dbms_scheduler.run_job('myjob');
BEGIN dbms_scheduler.run_job('myjob'); END;
ERROR at line 1:
ORA-27475: "CRDM.MYJOB" must be a job
ORA-06512: at "SYS.DBMS_ISCHED", line 150
ORA-06512: at "SYS.DBMS_SCHEDULER", line 441
ORA-06512: at line 1 -
Hello,
I would like to integrate some scripting capability in my web application.
The main purpose is to cover the following scenario :
- I develop a web app with JSP technology, packaged in a MyAPP.WAR file containing my application and another file (MyCustomer.RAR?) containing installation specific informations. I want the MyApp.WAR to be the same for all my customers, just having the RAR file specific to each customer (installation).
- In this ressource file, there could be some scripting functions that will be called from my JSP Pages to change the default presentation with some customer particular informations.
Those informations would be extracted from my java data model. The purpose is to enable the customer to code some little script, and to avoid coding those in Java.
The question I have on that are :
1/ is it possible to call java instances from scripting language (I read on apache that the answer was yes for some of them), but I would like to know if javascript can do that.
2/ Can I recover the "result" of the script in JSP ?
An example :
1/ The class containing a marvellous property
class MyClass {
public String myProperty;
2/ The JSP page :
<stlLib:callScript(Customer.RAR, "ScriptToCall",anInstance) />
<stlLib:getResult ???>
3/ A user script (pseudo-code)
Customer 1 :
Function ScriptToCall(object) {
variable iwanttoshowsquareroot;
iwanttoshowsquareroot = squareroot(object.myProperty);
return iwanttoshowsquareroot ;
Customer 2 :
Function ScriptToCall(object) {
variable mychoiceisdifferent;
mychoiceisdifferent= object.myProperty / 2;
return mychoiceisdifferent;
According to what ScriptToCall looks like the result on page would be different
Thanks in advance for your advises
Olivier.1) The script will be running in the browser, not the server, yes? So in Netscape you can load Java objects via Javascript, but IE doesn't seem to support this. Although in either, you can call methods on an applet in the page. But you can't call a JS function from the Java code in the JSP page, since that is only executed on the server.
2) Only if the "result" is submitted back to the server. -
Hello,
My question is on Script Applications in
Service Templates:
In VM Templates, in the Application Configuration tab, one can add a Script Application. This can be a PowerShell script, a batch script, etc.
For each Script Application, it is possible (via the Advanced options) to make the
machine reboot when the script exits with one of three
exit codes: 1641, 3010 and 3011.
Problem:
For PowerShell or PS scripts, if I use ‘exit 3010’, the machine should reboot but it doesn’t…
Bad workaround:
Use a batch script which calls the PS script. Then, exit out of the batch script using ‘exit $LASTEXITCODE’. This works. The machine reboots.
I can’t use the workaround. Is there a way to do this using just the PS script?
-Rohan.In fact yes.
You actually want SCVMM to orchestrate the reboot by sending the proper exit code. Otherwise SCVMM gets all weird about things.
It is in the advanced settings for the script and / or command.
You need to make sure that your script tosses the 3011 or 3010 on exit.
I do it with the 3011:
# Exit 3011
[Environment]::Exit(“3011”)
In the XML you will find this:
<vmmst:RebootExitCodeRegex>{1641}|{3010}|{3011}</vmmst:RebootExitCodeRegex>
But you do not want to enable restarting the script on each reboot or you will find yourself in a loop.
Brian Ehlert
http://ITProctology.blogspot.com
Learn. Apply. Repeat. -
Calling events from scripts in UIX
Hi,
I am able to call the ordinary events in the UIX from the script. But I am not able to call the
<ctrl:event .. >
from the script.
Could anyone please tell me how to call them.
Thank you
VelpandianVelpandian -
Assuming your page contains a form, you can trigger an event on the server from a JavaScript handler by calling submitForm(). The following sample shows how to send an event both by using the ctrl:event attribute as well as from a JavaScript handler:
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://xmlns.oracle.com/uix/controller"
xmlns:ui="http://xmlns.oracle.com/uix/ui"
xmlns:data="http://xmlns.oracle.com/uix/ui"
xmlns:ctrl="http://xmlns.oracle.com/uix/controller">
<content>
<form name="foo" xmlns="http://xmlns.oracle.com/uix/ui">
<contents>
<!-- Import the submitForm() function -->
<importScript names="submitForm()"/>
<stackLayout>
<contents>
<!-- This link sends an event using a ctrl:event attribute -->
<link text="Send Event" ctrl:event="test"/>
<!-- This link sends an event using a JavaScript event handler.
We use submitForm() and specify the event name using
a parameter. Note that this means that we need to be
sure that we also have an "event" hidden field - which
we add via a formParameter element below -->
<link text="Send Event from JavaScript"
onClick="if (confirm('Send event')) submitForm(0, 0, {'event':'test'}); else return false;"
destination="#"/>
<!-- Need a form value to contain the event name -->
<formParameter name="event"/>
</contents>
</stackLayout>
</contents>
</form>
</content>
<handlers>
<!-- Use a null event handler to set up a session variable -->
<event name="test">
<go name="nextPage"/>
</event>
</handlers>
</page>I couldn't find the documentation for submitForm() online anywhere... Here is a copy of the documentation from our source code:
* Attempts to submits the form, potentially firing validation and notifying
* any Cabo onSubmit handlers registered on the form, returning
* <code>true</code> if the submission actually occurred.
* <p>
* If the <code>doValidate</code> parameter is false, no validation will
* be performed, and the form is guaranteed to be submitted. Otherwise,
* the form will be submitted if both the validation succeeds and any
* registered Cabo onSubmit handlers do not return <code>false</code>.
* <p>
* @param form The form to submit. This can either be the name of the form
* in the current <code>document</code>, the index of the form
* in the current <code>document</code> or the form itself.
* @param doValidate boolean value specifying whether validation should
* occur before the form is submitted. (As per a common Javascript
* idiom, it is acceptable to pass true/false as well as 0/1). If
* this parameter is ommitted, it defaults to true.
* @param parameters a single Javascript object that specifies
* all the additional key-value pairs to submit. There must be
* pre-existing <input type="hidden"> elements as targets
* for each of these parameters.
function submitForm(
form,
doValidate,
parameters
)Andy -
Error while calling Subroutine from Script
HI Friends,
I am getting a short dump whilecalling a suboutine from Script.
Please suggest if am wrong with below code
/: PERFORM GET_ADDRESS IN PROGRAM ZSUBROUTINES
/: USING &MHND-KUNNR&
/: CHANGING &ADRS-LINE0&
/: CHANGING &ADRS-LINE1&
/: ENDPERFORM
All above fields are available in script window
In the program
FORM get_address TABLES in_tab STRUCTURE itcsy
out_tab stucture itcsy.
ENDFORM.
ThanksHI,
Your code is correct, in the FORM and ENDFORM in the program, read the INPUT table and get the values and write your logic using these values and send back the values to the SCRIPT using the OUTTABLE. here you need to use the MODIFY statment for the outtable using Sy-TABIX.
Regards
Sudheer -
Call script from script?
Is it possible to call a script from within another script?
Here's the catch: I'm using CS2 so I can't use $.evalFile (Script1) as it's not a recognised function.
CheersThis is an Xbytor snippet ...
var SCRIPTS_FOLDER = decodeURI(app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts"));
eval('//@include "' +SCRIPTS_FOLDER+ "/Add Texture.jsx" +'";\r'); -
Calling JVM from C native code
I'd like to call JVM from C native call.
I work in W2000 enviroment using GCC Cygnus compiler.
I followed JNI instructions.
I read in this forum there was a change in JDK, and instead of attaching javai.dll, jvm.dll must be attached.
Then I made a test using invoke.c example from JDK.
I built following .bat file:
gcc -c invoke.c -Id:\jdk1.3.1\include -Id:\jdk1.3.1\include\win32
DLLTOOL dllname jvm.dll def libjvm.def --output-lib d:\jdk1.3.1\jre\bin\classic\libjvm.a
c++ -o invoke.exe invoke.o -Ld:\jdk1.3.1\jre\bin\classic -ljvm
with libjvm.def :
EXPORTS
imp_JNI_GetDefaultJavaVMInitArgs@4
imp_JNI_CreateJavaVM@12
All seems to work fine, and invoke.exe is generated. But when trying to run it, I get a windows message telling me :
invoke.exe doesn't find the entry point to imp_JNI_CreateJavaVM@12 in jvm.dll.
What am I going wrong ?
Any calling convention issue ?
Thanks in advance. Ignasi Villagrasa.Have a look at http://www.xraylith.wisc.edu/~khan/software/gnu-win32/. It has examples of how to use gcc, java JNI on cygwin and should work on all versions of Windows. It has the command line options for using dlltool.
-
Excluding idoc processing from user exit code
Hi all,
In a user exit (for VA01 Create Sales Order) we are currently excluding certain order types by hardcoding the document type in the code. This is because some orders are created by IDoc and in this case the IDocs fail if they use the eser exit code (because the code creates pop-up messages intended for online users only). Not the best solution.
Does anybody know if we can use different code so that this part of the user exit does not get triggered by IDocs?
Thanks,
MikeI've figured out another solution - you can do a test on the field IDOC_NUMBER. If it is filled, then the sales order is created/changed via an Idoc.
-
Calling subroutine from scripts
I am calling a subroutine form a standard text, the subroutine is getting called but the input table is comming empty.
can any one please advise me what could be the problem.
/:PERFORM GET_APP_DATA IN PROGRAM YHR_APP_DATA
/:USING &P0001-PERNR&
/:CHANGING &GRADE&
/:ENDPERFORMCheck this sample code...may be it will help u to identify the prob...
Definition in the SAPscript form:
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/ &BARCODE&
Coding of the calling ABAP program:
REPORT QCJPERFO.
FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA: PAGNUM LIKE SY-TABIX, "page number
NEXTPAGE LIKE SY-TABIX. "number of next page
READ TABLE IN_PAR WITH KEY u2018PAGEu2019.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY u2018NEXTPAGEu2019.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY u2018BARCODEu2019.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = u2018|u2019. "First page
ELSE.
OUT_PAR-VALUE = u2018||u2019. "Next page
ENDIF.
IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = u2018Lu2019. "Flag: last page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
Regards,
JOy. -
Calculation of Tax Issue from FB60 (Tax Code Issue)
Dear All,
Normally when we purchase or received any services we post following entry.
INVOICE VALUE IS 1000
Purchase Ac Dr 1000
To Vendor 900
T o Tax 100
But our requirement is that
Purchase Ac Dr 1100
To Vendor 1000
T o Tax 100
System should add cost of TAX in purchase instead of reduction form vendor balance as we have to give 1000 RS to vendor.
Can we create TAX code in this manner.
This is not even possible form function available in Edit Option in FB60 (Calculate tax on Net Amount)
Not even from TDS (Withholding tax)
WE CANu2019T SUGGEST POSTING JV IN THAT CASE.
Regards,
BittuApologized for that Atif.
Withholding Tax Type does not control Vendor line item.
My issue is that system should not reduce value enter in vendor amount field.
System usually reduce amount which is payable to vendor
Please see my example once again. I also mention that it is not working from Withholding Tax nor form Tax code(FTXP)
Edit option in FB60 is also not useful in this case.
Regards, -
Is it possible to catch a PowerShell script output when an exit code is setted?
Hi,
i'm using TEO 2.1.2 with the hotfixes from 1 to 12 already installed and i have a problem using the "Execute Windows PowerShell Script" in reading the output of a PowerShell script if an exit code is expressly setted . For example if i try to execute a script like:
the output given by the activity is only 0 (like the exit code).
This is a problem if i use a script with multiple exit codes corrisponding to different kind of situations and different outputs like the following:
if($flag -eq "0")
Write-output "Hello"
exit 0
elseif ($flag -eq "1")
Write-output "Error 1"
exit 1
else
Write-output "Error 2"
exit 2
or if i call an executable which exit codes i want to identify by a readable description.
Anyone knows a way to solve this issue?
Thanks a lot,
bye.
GiulioThanks Shaun,
i was already looking toward this kind of approch, but i was also curious if there was a different way of doing this.
Anyway just a little annotation about your line of code, in Tidal 2.1.2 at least, Write-host doesn't work right, echo or Write-Output are fine but Write-host seems to be ignored. To the following script:
the output is
Maybe i'm missing something. Regarding an upgrade, as a devoloper i'd really like to try the improvement of the new version but this is not a decision I can make.
Thank you,
bye.
Giulio
Maybe you are looking for
-
I'm running Windows XP, using Linksys wireless router BEFW11S4, ver.2 I want to use the router's wireless capabilities, including use of a WEP. I can access the Setup page, entering with a password, but when I try to Apply my settings, the program in
-
Program freezes while running executables.
I'm working on a java installer & while doing the install the program window freezes until it's done. I'm trying to figure out how to make it not freeze so that I can implement some kind of progress bar. Here is the codes I'm using to install java I'
-
Kernel Errors!!!
Hi All I have a 15" PB Aluminum 1.5ghz with 1GB of ram. Just bought off a friend and when I did a fresh erase and install of OS X 10.4, repaired permissions and rebooted I get the kernel error telling me to hold down the power button and restart. So
-
Hi guys, Is there any iview to perform same as transaction vieiw in SAP EP? Thanks, Rajesh.
-
How to connect AS400 (best practice)
Hi folks, I'm trying to connect to an AS400 server and need expert advise to do so. I'm planning to use a JDBC driver to connect to the DB2400 database (for write/read into specific tables). What is the best way to reset AS400 user/password ? Use JDB