The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 03-04-2005
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
a few comments:

1. this
Code:
set -A instance
instance[1]="ont0"
instance[2]="qbc1"
instance[3]="jdbc0"
instance[4]="admin1"

can be made with that:

Code:
set -A instance 'ont0' 'qbc1' 'jdbc0' 'admin1'

the same goes for the OTHER array declaration/initialization.
btw, arrays are ZERO-based - not ONE-based

2.
Code:
function setYear{
  if [ ${DATEmonth} == 1 ]
  then
    DATEyear=${DATEyear}-1
  fi
}

DATEyear is declared as integer and should be compared as such.

Code:
if (( DATEmonth == 1 ))

and substraction should be performed as such:

Code:
(( DATEyear = DATEyear -1 ))

3. for your actual error.... - you need either a SPACE between the function name the trailing '{' OR you need to put '{' on a new line:

Code:
function setYear {

OR

function setYear
{

there are other potential problems with the script, but we'll go slow - fix the ones above first and start debugging the output next.

good luck.