Results 1 to 4 of 4
Hey im doing a project at the minute were i am asking for user input in form of a letter e.g. A or B then when they pick there option ...
- 12-08-2009 #1Just Joined!
- Join Date
- Nov 2009
- Posts
- 6
Unexpected end of a bash script
Hey im doing a project at the minute were i am asking for user input in form of a letter e.g. A or B then when they pick there option i want another script to run at the minute ive developed a script that should do this however it is coming up with an error that says there has been an unexpected end to the file. below is my code
[code]
#! /bin/bash
echo enter A to search word processing files and move to wp directory
echo enter B to search spreadsheet files and move to ss dir
read OPTION
if ['$OPTION' = A]
then
$ sh ~/my-documents/wpbasic
echo "great success"
if ['$OPTION' = B]
then
$ sh ~/my-documents/spreadsheetbasic
echo "great success"
fi
elif
echo "could not be processed"
fi
echo
echo finished
[\code]
- 12-08-2009 #2
My guess is that both if and elif need to have a corresponding fi.
Debian GNU/Linux -- You know you want it.
- 12-08-2009 #3Just Joined!
- Join Date
- Nov 2009
- Posts
- 6
Still got problems
i tryed removing the elif statement therefor i only have the one fi now but im still getting the same error
- 12-08-2009 #4
You're script is very messy. From reading it I think you have tried to take on to much to soon. Since it is homework we're not allowed to help you but I will say you should write the scripts in steps.
Your script is fine for taking input from the user so leave that as it is but try writing your code to check only for the user inputting the letter a. Then add the code to process the letter b. Then add the code to give an error message if the first two conditions aren't met
Also when executing an external script you just type sh followed by the script path/name. I think what you have done is copy the extra $ from an example somewhere. $ is just used normally to show that you type something into your console
Keep with it, you're almost there!Linux User #453176


Reply With Quote