What is wrong in this code
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 bashi 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
I suggest you have read a bash tutorial like this one. It will help you to get used to the bash syntax.
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.
精彩评论