Results 1 to 3 of 3
Hello everyone,
I'm having problems with a syntax error in an if then statement. The script is designed to allow the user to configure their computer to work with the ...
- 12-23-2010 #1Just Joined!
- Join Date
- Sep 2010
- Posts
- 8
[SOLVED] I'm having problems with an if then statement in a bash scrip
Hello everyone,
I'm having problems with a syntax error in an if then statement. The script is designed to allow the user to configure their computer to work with the ubuntu-manual project, and I decided to allow the user to choose whether or not to enter their launchpad username into bzr (in honesty, I did this because I don't have the RSA key set up on my test computer, and I don't want to have to do that to make the script work otherwise).
I'm getting
./configure-ubuntu-manual.sh: line 79: syntax error near unexpected token `fi'
./configure-ubuntu-manual.sh: line 79: `fi'
when I execute the script.
Here is the relevant portion of the script:
For reference, I've tried if [ $YAYNAY == "Y" ], if [ $YAYNAY = "Y" ], and every other combination of this. The only thing I haven't tried is removing the blank lines inside of the if statement.Code:echo echo "Do you wish to have bzr log you into launchpad? Note, that it will warn you if we don't configure a login, however you will still be able to download the files." read YAYNAY if [ $YAYNAY = 'Y' ] then echo echo "Please enter your launchpad username, in order to have write and other access to the project on the server. This is mainly because if we don't do this, bzr will put up a warning that states we don't have this access before it downloads the files. You will NOT be prompted for your password." read USERNAME bzr launchpad-login $USERNAME fi echo echo "Next, we will run bzr branch lp:ubuntu-manual to download our branch: This may take a few minutes, while bzr downloads the files for the project." bzr branch lp:ubuntu-manual
I've even tried an else statement. It's something inside of the "true" portion of the statement, because when I had the else statement, it triggered the error on 'else'.
I'm at a total loss here, as I've never programmed in bash (at least nothing this complex). I have a feeling it's something simple, like needing {}'s around the true statements, or a ; at the end of the last one. But, I'm lost.
Thanks for any help with this, and if you need the entire script, I'll be more than happy to post it.
Have a great day
Patrick.
- 12-23-2010 #2Linux Newbie
- Join Date
- Apr 2007
- Posts
- 119
Your if/then has to either be on different lines, or you need to use a semi-colon.
ORCode:if [ test ]; then echo answer fi
Code:if [ test ] then echo answer fi
- 12-23-2010 #3Just Joined!
- Join Date
- Sep 2010
- Posts
- 8



