Bad Substitution

Need Help... I am getting a bad substitution error on my script on a Solaris Server. However the script has been proven to work on HPUX and Solaris servers...

#!/usr/bin/sh
#
# Set the location of the tzupdater.jar file
#
JAR=/tmp/tzupdater.jar # <<<<< UPDATE THIS LINE >>>>>
#
# Clear out log files if they exist

if [[ -f /tmp/${0##/}.all_javas ]]; then
rm -f /tmp/${0##
/}.all_javas
fi
if [[ -f /tmp/${0##/}.old_javas ]]; then
rm -f /tmp/${0##
/}.old_javas
fi
if [[ -f /tmp/${0##/}.cur_javas ]]; then
rm -f /tmp/${0##
/}.cur_javas
fi

# Find all the files named java on the system
# and save the list in a log of all java files
find / -fstype nfs -prune -o -fstype autofs -prune -o -name java -type f -print -o -name java -type l -print | tee /tmp/${0##/}.all_javas | \
while read JAVA; do
exec 2>/dev/null # Ignore error messages
$JAVA -version >/dev/null 2>/dev/null # Check how java responds
if (( $? == 0 )); then # If RC=0, it is vaid
# Find out the version of Java this is
VERSION=$($JAVA -version 2>&1 | awk 'NR==1 {print substr($3,4,1)}')
if (( $VERSION > 3 )); then
# If the version is greater than 1.3, go ahead and update it
print "$($JAVA -version 2>&1 | awk 'NR==1 {print $3}')\t$JAVA" >> /tmp/${0##
/}.cur_javas # Save list of current Javas
# Check whether this java has been updated or not
$JAVA -jar $JAR -t >/dev/null 2>&1
if (( $? > 0 )); then # If not updated, update it
print "Updating $JAVA"
$JAVA -jar $JAR -u
else # Otherwise, print a message already updated
print "$JAVA already updated"
fi
else # This cmd is an old version of Java
print "$($JAVA -version 2>&1 | awk 'NR==1 {print $3}')\t$JAVA" >> /tmp/${0##*/}.old_javas # Save list of old Javas
fi
fi
done
#

Try changing
#!/usr/bin/sh
to
#! /usr/bin/ksh

Thanks... That worked? Any idea script worked in both HPUX and RHEL, but had to be changed in Solaris??? :slight_smile:

On RHEL, /usr/bin/sh is bash. On hp-ux it is "posix shell" based on ksh. On Solaris, it really is sh, the old Bourne shell.