1/*****************************************************************************/ 2/* Software Testing Automation Framework (STAF) */ 3/* (C) Copyright IBM Corp. 2001 */ 4/* */ 5/* This software is licensed under the Eclipse Public License (EPL) V1.0. */ 6/*****************************************************************************/ 7 8/*********************************************************************/ 9/* Sample1.cmd - Rexx sample program using STAF */ 10/*********************************************************************/ 11/* This sample loads the STAF Functions, registers to STAF, queries */ 12/* a global variable from STAF, inititates a synchronous process */ 13/* which is a chkdsk of the boot drive, then unregisters. */ 14/* */ 15/* Returns: 0, on success */ 16/* >0, if an error is encountered */ 17/*********************************************************************/ 18/* Date Who Comment */ 19/* ---------- ------------ --------------------------------------- */ 20/* 02/01/1998 D. Randall File Created */ 21/*********************************************************************/ 22SIGNAL ON HALT NAME STAFAbort 23 24/* Load STAF functions */ 25call RxFuncAdd "STAFLoadFuncs", "RXSTAF", "STAFLoadFuncs" 26call STAFLoadFuncs 27 28/* Register to STAF */ 29call STAFRegister "STAF_REXX_Sample1" 30if RESULT \= 0 then 31do 32 say "Error registering to STAF:" RESULT 33 RETURN RESULT 34end 35 36/* Query STAF for a variable */ 37STAFRC = STAFSubmit("local", "var", "resolve {STAF/Config/BootDrive}") 38if STAFRC = 0 then 39 bootdrive = STAFResult 40else 41do 42 say "Unable to determine boot drive!" 43 call STAFUnRegister 44 RETURN STAFRC 45end 46 47/* Build the process start request with a work load name of STAFSample */ 48request = "START WAIT COMMAND chkdsk.com WORKLOAD STAFSample" 49 50/* Pass the boot drive parameter to chkdsk */ 51parms = "PARMS" bootdrive 52 53/* Query STAF for a variable */ 54STAFRC = STAFSubmit("local", "var", "resolve {STAF/Config/Sep/File}") 55if STAFRC = 0 then 56 filesep = STAFResult 57else 58do 59 say "Unable to determine file seperator!" 60 call STAFUnRegister 61 RETURN STAFRC 62end 63 64/* Set the working directory */ 65workdir = "WORKDIR" bootdrive||filesep 66 67/* Submit the request to STAF */ 68say "Attempting to CHKDSK bootdrive" bootdrive 69STAFRC = STAFSubmit("local", "process", request parms workdir) 70say "Submit Return Code="STAFRC ", Result="STAFResult 71 72/* Unregister */ 73call STAFUnRegister 74RETURN 0 75 76/*********************************************************************/ 77/* STAFAbort - If user aborts, make sure STAF unregister occurs. */ 78/*********************************************************************/ 79STAFAbort: 80 call STAFUnRegister 81 EXIT 1 82