Reputation: 11
Im new to unix command. I would like to execute jasper file P70152R1 and pass busDt param to that file. Currently hit this error >>> line 51: syntax error at line 53: `newline' unexpected
Can anyone help me to check my shell script.
Below is my script:
echo "*********************************************************"
echo "* xxxxxxxxxxxxxxxxxxxxxxxxx *"
echo "*********************************************************"
echo
echo "*********************************************************************************"
echo "* xxxxxxxxxxxxxxxxxxxxxxxx *"
echo "* UP *"
echo "* P700152R1 - AAAAAAAAAAAAAAAAAAA REPORT *"
echo "* P700152R2 - BBBBBBBBBBBBBBBBBBB REPORT *"
echo "* P700152R3 - CCCCCCCCCCCCCCCCCCC REPORT *"
echo "* (JP700152) *"
echo "* FREQUENCY : DAILY *"
echo ****************************************************************************"
echo
cd $MAIN/CWJCL/ACQ
export JCL=$MAIN/CWJCL/ACQ
export PRM=$MAIN/CWPRM/ACQ:$MAIN/CWPRM/CMN
export JAS=$MAIN/CWRPT/ACQ
export rptDir=$MAIN/ACQ/DAILYRPT
export LOG=$MAIN/CWLOG/ACQ
echo "Start Time and Date : \c" &&date
echo
JP70152=`date +%Y%m%d%H%M%S`
$JCL/strtJob $JP70152 JP70152
# Classpath
. $JCL/SETENV
#export CLASSPATH=$CLASSPATH:$PRM:$LIB/acq-1.0.jar
export CLASSPATH=$CLASSPATH:$PRM:"$MAIN/CWLIB/classes/acq"
# Get Business Date
echo "set heading off;" > $LOG/busDtSel.sql
echo "spool $LOG/date.log;" >> $LOG/busDtSel.sql
echo "ALTER SESSION SET CURRENT_SCHEMA=CCPS;" >> $LOG/busDtSel.sql
echo "SELECT 'CURRENT-BUSS-DATE:'||F9_AP008_BUS_DT FROM AP008;" >> $LOG/busDtSel.sql
echo "spool off;" >> $LOG/busDtSel.sql
echo "EXIT;" >> $LOG/busDtSel.sql
echo
$JCL/CONNAM.sh $LOG/busDtSel.sql $LOG/sel_day
a=$?
if [ ! $a -eq 0 ]
then
return $a
fi
tmpDt=`grep CURRENT-BUSS-DATE $LOG/date.log`
busDt=${tmpDt##*:}
# run program.
yyyymmdd=`date +%Y%m%d`
$JAVA_HOME/bin/java my.com.eprotea.report.JRGenerator -Ttxt -J$JAS/P70152R1.jasper -DACQ -O$rptDir/P70152R1.rpt -P<BUS-DATE:$busDt>
##########$JAVA_HOME/bin/java my.com.eprotea.report.JRGenerator -Ttxt -J$JAS/P70152R2.jasper -DACQ -O$rptDir/P70152R2.rpt -P<BUS-DATE:$busDt>
##########$JAVA_HOME/bin/java my.com.eprotea.report.JRGenerator -Ttxt -J$JAS/P70152R3.jasper -DACQ -O$rptDir/P70152R3.rpt -P<BUS-DATE:$busDt>
a=$?
echo $a
if [ ! $a -eq 0 ]
then
return $a
fi
echo
echo
echo
$JCL/endJob $JP70152 JP70152
echo "End Time and Date : \c" &&date
echo
return $a
Really appreciate your help. Thanks id advance !
Upvotes: 0
Views: 20383
Reputation: 4979
The <
and >
characters have a special meaning in bash. You used them in
echo "set heading off;" > $LOG/busDtSel.sql
to redirect the output of the echo to $LOG/busDtSel.sql
.
In your line 53, you do:
$JAVA_HOME/bin/java my.com.eprotea.report.JRGenerator options -P<BUS-DATE:$busDt>
That means that the last argument for the JRGenerator
is -P
, that the stdin comes from the file BUS-DATE:$busDt
and that stdout goes to, ehm, nothing. There is a new-line. That is unexpected for bash, because it expected a destination for stdout. Hence the error message.
The solution is to use quotes:
$JAVA_HOME/bin/java my.com.eprotea.report.JRGenerator options "-P<BUS-DATE:$busDt>"
There are other issues in your script as well; for example: there is a line with:
echo ************************************"
which should obviously be:
echo "************************************"
I think that this might be a mistake in putting the script in the question, because this generates a different error message for me.
Upvotes: 2
Reputation: 5591
Hi you are using >
operator at the end of your java command. Better use a escape sequence to overcome this issue. See below correct expression.
$JAVA_HOME/bin/java my.com.eprotea.report.JRGenerator -Ttxt -J$JAS/P70152R1.jasper -DACQ -O$rptDir/P70152R1.rpt -P\<BUS-DATE:$busDt\>
or, you can try like below as Ljm provided in his answer:-
$JAVA_HOME/bin/java my.com.eprotea.report.JRGenerator -Ttxt -J$JAS/P70152R1.jasper -DACQ -O$rptDir/P70152R1.rpt "-P<BUS-DATE:$busDt>"
Upvotes: 1
Reputation: 405
You forgot to add a "
at the beginning of a line and therefore screws up everything:
echo "*********************************************************************************"
echo "* xxxxxxxxxxxxxxxxxxxxxxxx *"
echo "* UP *"
echo "* P700152R1 - AAAAAAAAAAAAAAAAAAA REPORT *"
echo "* P700152R2 - BBBBBBBBBBBBBBBBBBB REPORT *"
echo "* P700152R3 - CCCCCCCCCCCCCCCCCCC REPORT *"
echo "* (JP700152) *"
echo "* FREQUENCY : DAILY *"
HERE -> echo ****************************************************************************"
Upvotes: 1