Linux script
The Code Review component provides a sample script for running the code review application from a Linux® command line.
The following block of code shows the Linux script. Before you run the script, ensure that the DISPLAY environment variable is set to a valid X server and display number.
#!/bin/sh
#############################################################################
# #
# Developer for z/OS 5724-T07 #
# #
# Copyright IBM Corp. 2012, 2024 All rights reserved. #
# All rights reserved. US Government Users Restricted Rights - #
# Use, duplication or disclosure restricted by GSA ADP Schedule Contract #
# with IBM Corp. #
# #
#############################################################################
usage()
{
echo
echo "codereviewbatch -workspace ws_location -rulefile rule_file"
echo " -exportdir exp_location [-directory dirs] [-projects projs]"
echo " [-includefile in_file] [-excludefile ex_file] [-outputfile out_file]"
echo
echo " ws_location The workspace location"
echo " rule_file The file containing exported rules to be executed"
echo " exp_location The directory where data files are written"
echo " dirs Comma-separated directories containing source"
echo " projs Comma-separated workspace projects containing source"
echo " in_file File containing list of files to include in analysis"
echo " ex_file File containing list of files to exclude from analysis"
echo " out_file Target file for command output"
echo
echo Use -debug to print command output to the console.
echo
echo "The correct usage of this tool is described in the on-line documentation"
echo "for Developer for z/OS."
return
}
rdz_install_dir=@RDZINSTALLDIR@
# supply defaults if desired
workspace=
rulefile=
exportdir=
directory=
projects=
includefile=
excludefile=
outputfile=
debug=
# process parameters
while [ $# -gt 0 ]
do
case "$1" in
-workspace ) workspace=$2; shift 2;;
-rulefile ) rulefile=$2; shift 2;;
-exportdir ) exportdir=$2; shift 2;;
-directory ) directory=$2; shift 2;;
-projects ) projects=$2; shift 2;;
-includefile ) includefile=$2; shift 2;;
-excludefile ) excludefile=$2; shift 2;;
-outputfile ) outputfile=$2; shift 2;;
-debug ) debug="true"; shift 1;;
# unknown parameter
* ) echo "Ignoring parameter: $1"; shift 1;;
esac
done
# workspace, rulefile, exportdir are mandatory
if [ "$workspace" == "" ]
then
echo "-workspace parameter is mandatory"; usage
elif [ "$rulefile" == "" ]
then
echo "-rulefile parameter is mandatory"; usage
elif [ "$exportdir" == "" ]
then
echo "-exportdir parameter is mandatory"; usage
else
# construct parameters and command
ap_parm="-application com.ibm.rsaz.analysis.commandline.AnalyzeApplication"
ws_parm="-data $workspace"
rf_parm="-rulefile $rulefile"
exp_parm="-exportdirectory $exportdir"
dir_parm=
if [ "$directory" != "" ]
then
dir_parm="-directory $directory"
fi
proj_parm=
if [ "$projects" != "" ]
then
proj_parm="-projects $projects"
fi
in_parm=
if [ "$includefile" != "" ]
then
in_parm="-includefile $includefile"
fi
ex_parm=
if [ "$excludefile" != "" ]
then
ex_parm="-excludefile $excludefile"
fi
command="""$rdz_install_dir/eclipse"" $ap_parm $ws_parm $rf_parm $dir_parm $proj_parm $in_parm $ex_parm $exp_parm -verbose -nosplash"
# run command
echo "Running software analysis..."
echo $command
if [ "$outputfile" != "" ]
then
$command > $outputfile
if [ "$debug" == "true" ]
then
cat $outputfile
fi
else
$command
fi
fi