views:

161

answers:

2

Here i have got various inputs from keyboard and checked these validations

Book_id must be unique.
Subject code can only be either UNIX or C.The Shelll i work is bash

i got the following errors

./test.sh: line 5: declare: `=0': not a valid identifier
/test.sh: line 13: unix: command not found
./test.sh: line 92: syntax error: unexpected end of file

    echo -n "Enter Book Accession number: "
        read Book_accession_number

        declare -a var_id
        declare -i i =0

        subject()
        {
        echo -n "Enter Subject code:"

        read Subject_code

        if ("$Subject_code" !=  "unix")
        then
{
        if ("$Subject_code"  !=  "c")
        then
{
        echo "please enter unix or c"
        subject
        }
        fi
}
        fi


        subject
        Book()
        {
        echo -n "Enter Book ID:"
        read Book_id
        echo -n "Enter Book Accession number: "
        read Book_accession_number

        declare -a var_id
        declare -i i =0






        while(j -ne i)
        {
        j++
        if(var_id[i]==Book_id)
        then
        {
        echo "please enter a unique id"
        Book
}
        fi


        }

        Book


        echo -n "Enter Author Name:"
        read Author_name

        echo -n "Enter Year of Publication:"

        read YOP

        echo -n "Enter Title of Book:"

        read TOB

        echo -n  "Enter Publisher's name:"

        read PUB_Name;

        echo -n "Enter Price: "
        read Price
+1  A: 

I suggest you have read a bash tutorial like this one. It will help you to get used to the bash syntax.

Aaron Digulla
+1  A: 

first one is no space should be placed between variable and = symbol. like x=0;

second one is in the IF conditions use the [] or (( )) instead of () symbol.

3rd one, i dont see any 92nd line in ur script. I suggest you to try putting a new line (empty line) after the last line of your code.

Venkataramesh Kommoju
i m not able to solve this error ./test.sh: line 92: syntax error: unexpected end of file what should i do
Arunachalam
hi arunachalam,is that the whole code you are using? if so i cant see a 92nd line. however i found one more thingin the function Book, chage the line declare -i i =0 to declare -i i=0 [ remove space before = sign]
Venkataramesh Kommoju