hi guys i know this question has been asked several time out there.But i have tried a lot and i am not able to get what is the issue .Below is my code -:
#!/bin/bash
#GLOBAL VARIABLE
name=()
browserTime=0
browserScriptLocation=/global/z1/siebel/sweapp/public/enu
value=0
browserintegerDate=0
browserscript_CreationTime(){
# SET PATH
cd $browserScriptLocation
#LOOP INSIDE THE FILES PRESENT ON PARTICULAR PATH
for entry in $(ls -t | grep "srf*")
do
#APPEND SEARCHED FILE IN ARRAY AT INDEX 0
name[value]="$entry"
#INCREASE INDEX COUNT
value+=1
done
name=${name[0]}
echo "$name"
#GET BROWSER SCRIPT TIME
browserTime=$(ls -E "$name" | cut -c 52-60)
echo "$browserTime"
browserDate=$(ls -E "$name" | cut -c 41-51)
echo "$browserDate"
year=$(echo "$browserDate" | cut -c 1-5)
month=$(echo "$browserDate" | cut -c 7-8)
date=$(echo "$browserDate" | cut -c 10-11)
browserintegerDate="$year$month$date"
browserintegerDate+=$(echo $timeConversion)
echo "$browserintegerDate"
}
#invoke your function
browserscript_CreationTim
I am getting this error-: name[value]: bad array subscript
.The same code i have tested on other UNIX BOX. Both having same OSversion (SunOS 5.10) and it works fine over there.But it is not working on another one.I am not getting why is this happening?? Can anyone help??