Seeking for your assistance on my error encountered below. I think there's no problem on my script but i'm encountering integer expression expected. i already put double quote on my variable but still the same error i encountered.
#!/bin/sh
TASKDATE=2016-02-10
VSQL_F="connect"
dProcDate=`${VSQL_F} <<-EOF
SELECT LAST_DAY('$TASKDATE') AS dProcDate FROM DUAL;
EOF`
dCurrent=`${VSQL_F} <<-EOF
SELECT LAST_DAY(SYSDATE) AS dCurrent FROM DUAL;
EOF`
dProcDate2=`${VSQL_F} <<-EOF
SELECT LAST_DAY(ADD_MONTHS(SYSDATE,-1)) AS dProcDate FROM DUAL;
EOF`
if [ "$dProcDate" -lt "$dCurrent" ]; then
$dProcDate
else
$dProcDate2
fi
echo $TASKDATE
echo $dProcDate
echo $dCurrent
echo $dProcDate2
Error encountered:
jpv2.sh: line 18: [: 2016-02-29: integer expression expected
jpv2.sh: line 21: 2016-04-30: command not found
2016-02-10
2016-02-29
2016-05-31
2016-04-30
You need convert it to seconds so you can use comparison operator in condition. Date format (2016-02-28) is not an integer , that's why script was throwing an error.
That will work with some shells (and with some versions of the stand-alone
test
/ [ utilities), but the only string comparison operators defined for test in the standards are = and != .
We know that the submitter is using /bin/sh , but that isn't enough to know what operating system is being used nor what shell has been designated as /bin/sh on the submitter's system.