5 Replies - 1946 Views - Last Post: 10 October 2013 - 08:07 AM Rate Topic: -----

#1 shaunarman  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 62
  • Joined: 21-January 10

AIX Syntax error using ksh script

Posted 05 October 2013 - 12:14 PM

Hi all, im back with a new issue :stupid:/>

OK, first off, I know bash is the prefered envirnment, but I do not have the pleasure to install the bash environment on all my servers, I am just a low end system admin lol.

The issue I get is when I go and run my script I am being presented with this error:
0403-057 Syntax error at line 66 : `}' is not expected.


I am new to AIX, but the commands are similure to most Linux commands, and my scripting is amature at best, but I do try to do my best.
In my code you will note that line 63 simply contains a bunch of comment marks "########", so I do not understand why/how the script is seing a "}" on that line :gun_bandana:/>

#!/bin/ksh
#########################################
#       Author: Me
#       Contact: <You wish you could get my email>
#       Title: add_filesystem.sh
#
#       Description: This script will
#       automate the filesystem creation
#       and mounting
#
#       Prereq's: You must have already
#       had storage add the storage
#       and have it avalible for use in a vg
##########################################


##########################################################################
######				Functions      			    ######
##########################################################################

function Select_VG
{
echo "What VoulmeGroup do you want to use?: "
lsvg >> vg.txt
cat vg.txt
read vg
}

##########################################################################

function Make_VG
{
echo "What do you want to call the VG?: "
	read vg_name
	echo "How big do you want to make the VG?: "
	read vg_size
	echo "What is the 1st. hdiskpower you want to use?: "
	read hdisk
}

##########################################################################

function Extend_VG
{
extendvg $vg $hdisk
tempvg=1

until [ $tempvg = "no" ]
	do
	extendvg $vg $hdisk
	echo "Do you have more hdiskpowers to add (Yes/No)? [n]: "
	read hanswer
		until [ "$hanswer" = "0" ]; do
		case $tempvg in
       			y|Y|yes|Yes) tempvg="yes";;
			n|N|No|no) tempvg="no";;
			*) echo "Please enter a valid option."; press_enter
#		esac
#			if [$tempvg -eq "no"]
#			then
#				break
#			fi
#done

}

##########################################################################

function Set_nbpi
{
selection=
until [ "$selection" = "0" ]; do
	echo "\n"
	echo "Please select your NBPI options from below."
	echo "\n"
	echo "1 - 512 (Max 8GB filesystem)"
	echo "2 - 1024 (Max 16GB filesystem)"
	echo "3 - 2048 (Max 32GB filesystem)"
	echo "4 - 4096 (Max 64GB filesystem)"
	echo "5 - 8192 (Max 128GB filesystem)"
	echo "6 - 16384 (Max 256GB filesystem)"
	echo "7 - 32768 (Max 512GB filesystem)"
	echo "8 - 65536 (Max 1024GB filesystem)"
	echo "9 - 131072(Max 1024GB filesystem)"
	echo "x - Exit the program"
	echo "Default option would be 4"
	print -n "       Enter your selection: \n"
	read selection
		case $selection in
       			1) nbpi='512';;
       			2) nbpi='1024';;
       			3) nbpi='2048';;
       			4) nbpi='4096';;
       			5) nbpi='8192';;
       			6) nbpi='16384';;
       			7) nbpi='32768';;
       			8) nbpi='65536';;
       			9) nbpi='131072';;
			x) clear ; exit ;;
        		*) echo "Please enter your selection "; press_enter
			esac
}

##########################################################################

function Verify
{
echo "#########################################" >> verify.txt
echo "### Filesystem Verification of $host ###\n" >> verify.txt
echo "#########################################" >> verify.txt
echo "\n\n\n\n\n"
echo "######################################" >> verify.txt
echo "### Verifying mount of $mount_path ###\n" >> verify.txt
echo "######################################" >> verify.txt
mount | grep $mount_path >> verify.txt
echo "\n\n\n\n\n"
echo "########################################" >> verify.txt
echo "### Verifying storage of $mount_path ###\n" >> verify.txt
echo "########################################" >> verify.txt
df -g | grep $mount_path >> verify.txt
echo "\n\n\n\n\n"
echo "######################################" >> verify.txt
echo "### 	End of Script 		 ###\n" >> verify.txt
echo "######################################" >> verify.txt
}

##########################################################################

function Set_size
{
echo "How must storage do you want to allocate to the new filesystem? Input will be in MB's: "
read size
}

##########################################################################

function Set_mount
{
echo "What is the path where you want to mount this filesystem?: "
read mount_path
}

##########################################################################

function Make_fs
{
crfs -v jfs -g $vg -a size=($size)M bf=true compress=no nbpi=$selection -m $mount
}

##########################################################################
######				End of Functions		   ######
##########################################################################







##########################################################################
######				Menu				   ######
##########################################################################
# Menue for Script commands
tempdata=
	until [ "$tempdata" = "0" ]; do
		echo ""
		echo "		Create a New Filesystem"
		echo ""
		echo "L - List avalible VG's on the stsem."
		echo "1 - View a list of current VG's on the system"
		echo "2 - Extend a existing filestsem."
		echo "3 - Create a new VG."
		echo "4 - Set the total amount of storage to allocate to the new Filesystem."
		echo "5 - Set the path of the new filesystem. Exp. /mnt/new_filesystem/"
		echo "6 - Select your nbpi options."
		echo "7 - Create the acutal filesystem and mount it."
		echo "X - Exit the program"
		echo ""
		print -n "		Enter your selection."
			read tempdata
		case $tempdata in
			L) lsvg;;
			l) lsvg;;
			1) echo "" ; Select_VG ;; 
			2) echo "" ; Extend_VG ;;
			3) echo "" ; Make_VG ;;
			4) echo "" ; Set_size ;; 
			5) echo "" ; Set_mount ;; 
			6) echo "" ; Set_nbpi ;;
			7) echo "" ; Make_fs ;;
			X) clear ; exit ;;
			x) clear ; exit ;;
			*) echo "Please enter your selection "; press_enter
		esac
cat verify.txt
	done



Any advise is welcome, but please remember I can not use bash.

Is This A Good Question/Topic? 0
  • +

Replies To: AIX Syntax error using ksh script

#2 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1398
  • View blog
  • Posts: 4,873
  • Joined: 19-February 09

Re: AIX Syntax error using ksh script

Posted 05 October 2013 - 12:30 PM

It might be you're not ending the case statement.

058	#       esac


Was This Post Helpful? 0
  • +
  • -

#3 shaunarman  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 62
  • Joined: 21-January 10

Re: AIX Syntax error using ksh script

Posted 05 October 2013 - 12:39 PM

OK, ber some suggestions on Freenode I modified it a little:
function Extend_VG
{
extendvg $vg $hdisk
tempvg=1

until [ $tempvg = "no" ]
        do
        extendvg $vg $hdisk
        echo "Do you have more hdiskpowers to add (Yes/No)? [n]: "
        read hanswer
                until [ "$hanswer" = "0" ]; do
                case $tempvg in
                        y|Y|yes|Yes) tempvg="yes";;
                        n|N|No|no) tempvg="no";;
                        *) echo "Please enter a valid option."; press_enter;;
                esac
#                       if [$tempvg -eq "no"]
#                       then
#                               break
#                       fi
done

}



I still get the same error about line 66 if I add
;;[.code] after [code]press_enter
and uncomment
esac

Was This Post Helpful? 0
  • +
  • -

#4 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1398
  • View blog
  • Posts: 4,873
  • Joined: 19-February 09

Re: AIX Syntax error using ksh script

Posted 09 October 2013 - 10:01 AM

Hi, you have two dos so do you need two dones?
Was This Post Helpful? 0
  • +
  • -

#5 shaunarman  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 62
  • Joined: 21-January 10

Re: AIX Syntax error using ksh script

Posted 10 October 2013 - 06:00 AM

Yes there are a few does in there. I'm sure I can weed them out, but this is just the start of the script, I'm still refining and twee king it

Sent from my Galaxy Nexus using Xparent Skyblue Tapatalk 2
Was This Post Helpful? 0
  • +
  • -

#6 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1398
  • View blog
  • Posts: 4,873
  • Joined: 19-February 09

Re: AIX Syntax error using ksh script

Posted 10 October 2013 - 08:07 AM

Hi, yep I would think that because you use two of do you need two of done.


21	  done
22	done 
23	}




function Extend_VG
{
  extendvg $vg $hdisk
  tempvg=1

  until [ $tempvg = "no" ]
  do
    extendvg $vg $hdisk
    echo "Do you have more hdiskpowers to add (Yes/No)? [n]: "
    read hanswer
      
    until [ "$hanswer" = "0" ]; 
    do
      case $tempvg in
           y|Y|yes|Yes)  tempvg="yes";;
           n|N|No|no)    tempvg="no";;
           *)            echo "Please enter a valid option."; press_enter;;
      esac
#                       if [$tempvg -eq "no"]
#                       then
#                               break
#                       fi

    done
  done
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1