Created
July 14, 2019 20:01
-
-
Save iversond/f9410411d10049a805353ea65d99a690 to your computer and use it in GitHub Desktop.
David's Kurtz's wrapper script - using bash instead of ksh - http://www.go-faster.co.uk/scripts/psft.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# (c) David Kurtz 2007 | |
# Script: psft.sh | |
# | |
# Syntax: psft.sh DBNAME ACCESSID ACCESSPSWD PRCSINSTANCE | |
# where | |
# DBNAME is the name of the PeopleSoft datbase with a corresponding TNS entry | |
# ACCESSID is the schema containing the PeopleSoft database | |
# ACCESSPSWD is the password to ACCESSID | |
# PRCSINSTANCE is the process instance number supplied by PeopleSoft | |
# | |
# Purpose: To start Standard UNIX Shell Script from Process Scheduler, and interface with the PeopleSoft Process Scheduler | |
# 07.09.2007 Initial Version | |
# 23.02.2017 Remove unnecessary logfiles section | |
#set -x | |
if [ $# -lt 4 ]; then | |
echo "Usage $0: <DBNAME> <ACCESSID> <ACCESSPSWD> <PRCSINSTANCE> <command>" | |
exit 1 | |
fi | |
CONNECT=$2/$3@$1 | |
PRCSINSTANCE=$4 | |
shift 4 | |
# | |
# Function to set status of API aware process instance | |
# | |
function prcsapi | |
{ | |
if [ $# -lt 2 ]; then | |
echo "Parameter Error in function $0" | |
exit 1 | |
fi | |
TIMESTAMPCOL=${1} | |
STATUS=${2} | |
if [ ${PRCSINSTANCE} -gt 0 ];then | |
echo "Setting process request ${PRCSINSTANCE} to status ${STATUS}" | |
sqlplus -S /nolog <<! | |
set termout off echo off feedback off verify off | |
connect ${CONNECT} | |
UPDATE psprcsque | |
SET runstatus = ${STATUS} | |
, sessionidnum = $$ | |
, lastupddttm = SYSTIMESTAMP | |
WHERE prcsinstance = ${PRCSINSTANCE} | |
; | |
UPDATE psprcsrqst | |
SET runstatus = ${STATUS} | |
, prcsrtncd = ${PRCSRTNCD} | |
, continuejob = DECODE(${STATUS},2,1,7,1,9,1,0) | |
, ${TIMESTAMPCOL} = SYSTIMESTAMP | |
, lastupddttm = SYSTIMESTAMP | |
; | |
COMMIT; | |
exit | |
! | |
RET=$? | |
if [ ! $RET ];then | |
echo "SQL*Plus Error Return Code: $?" | |
fi | |
fi | |
} | |
# | |
# Main Execution Starts Here | |
# | |
echo $0:$* | |
date | |
uname -a | |
echo "Current Directory: `pwd`" | |
echo "Process log files in: ${PSPRCSLOGDIR}" | |
PRCSRTNCD=0 | |
prcsapi begindttm 7 | |
#set | |
#Run the command | |
$* | |
PRCSRTNCD=$? | |
if [ ${PRCSRTNCD} -ne 0 ]; then | |
prcsapi enddttm 3 # failure | |
else | |
prcsapi enddttm 9 # success | |
fi | |
date | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment