Shell Text Based Game, This Error Makes NO sense. Please help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Text Based Game, This Error Makes NO sense. Please help
# 1  
Old 11-17-2012
Bug Shell Text Based Game, This Error Makes NO sense. Please help

Okay so I'm making a simple text based game that branches into different scenarios. By branching I mean branching off into whole different files with that part of the game in it. I got tired of working on scenario 1 so I'm working on scenario 2. As I get started and try to test it, I get an error that makes absolutely no sense. This code should work. Other than echo'ing text to progress the story line, all I had to do was copy and paste some of the exact same code into this scenario. I will post the terminal error I'm getting first and then post the code. Please tell me if you see an error.
ERRORS:
/bin/ap_test2: line 62: syntax error near unexpected token `fi'
/bin/ap_test2: line 62: `fi'

Note that I have marked line 62 in the code for the purpose of assistance. the numbers 62 are not really in the code

Code:
#!/bin/bash

echo "

Great, you get to figure out how to upgrade the main version of the  software on the older device. Once you're done with that, we will use a  software dump to figure out the differences in old and new. We will  incorporate the new features on the old and prove whether Apple is being  honest to the public about being able to upgrade their software!

"
    read return
echo "Cyna walks up to you and hands you a flash drive. 'On this is  everything that we have developed here in OTA to rip apart Apple  software, including an emulator which will run as soon as you boot up  the device on which you are working. The terminal has a debugging bridge  which pulls and records every single process that runs as soon as you  press the power button on the device. Now head over to your brand new  office, make yourself at home and get started with that mainver upgrade.
"
    read return
echo "You walk into the office, and it is amazing. There are plants  surrounding the office, and a ceiling that simulates the current  conditions of the sky outside the building. The whole right side of the  office is laden with a huge desk with multiple monitors, PC's, cables,  external HDD's, and various Raspberry Pi looking devices that are  probably used to simulate the current devices on which OTA is working.  Perpendicular to the right wall is a table on the left wall with fresh  cupcakes, donutes, eclairs, froyos, gingerbread androids, honeycombs, a  bowl of jelly beans, a key lime pie, and a mini-freezer with  android-shaped ice cream sandwiches. There is a refrigerator with fresh  made lemonade, orangeade, cans of Mountain Dew, and Peach Bellini Tea."


echo "You sit down in a chair that feels like a Tempurpedic as it molds  to your back and turn on the super PC in front of you. As you look at  it, there are eight buttons on the front, each for a different Operating  System, with 7 and 8 being automatically known to be repair terminal  and a Windows safe mode, you read a post-it note left by whomever was  here last that reads ***Backtrack seems to be the only distro that would  establish communication with the Ray*** ."
        read return
echo "Well I guess I should use Backtrack"
        read return
echo -n "
    Which OS would you like to use? (Enter a number)
    1 ) Ubuntu
    2 ) Gentoo
    3 ) Linux Mint
    4 ) Backtrack Linux
    5 ) Fedora
    6 ) Windows

"
read distro
    case distro in
    4 ) echo "You chose Backtrack Linux, now booting Backtrack Linux"
    ;;
    * ) echo "You chose $distro, now booting OS"
esac

echo "I guess I should boot up securely, as in disable wifi, boot up,  setup my username and password, write a boot script to disable wifi  unless I initiate it, and restart the computer and change all my  credentials."
        read return
"Now I've disabled wifi, time to boot up"

echo "The button is pressed and no sound is heard except a brief sucking  sound which is the aqua-cooling system setting its pressure. Blue  lights shine from the side out of an intricate hex-in-hex patterned  plexiglass. You see the drive deck at station 4 move backwards and then  lift up into a resting place. You can see the fans begin to work inside  and with a press of a button on top by the USB 7.0 Port, the speed of  the fans can be set. I will leave this alone for now. the wifi button is  still lit up brightly white."

echo "A setup screen pops up asking generic installation question, time  zone, partitions, etc. Then the User setup screen pops up...."
        read return

echo -n "Enter username > 
"
    read username
    echo -n "Enter a strong password >
"
    read -s userpass
    echo -n "Enter password again >
"
    read -s userpass1
        { 
         if [ $userpass != $userpass1 ]; then
     echo "Your passwords did not match. Please re-enter a new one."
     read -s userpass
     echo "Enter password again"
     read -s userpass1
     fi
        }
fi    *****LINE 62******
        read return
echo "Now that I've got that boot script written for the wifi, I'll  restart the computer and reset my username and login just in case  somehow the connection to this computer was compromised, or someone in  OTA (God I hope not) has alterior motives."
        read return

# 2  
Old 11-17-2012
you frogot the ;; after the line
Code:
* ) echo "You chose $distro, now booting OS"

# 3  
Old 11-17-2012
Quote:
Originally Posted by complex.invoke
you frogot the ;; after the line
Code:
* ) echo "You chose $distro, now booting OS"

That should not be a problem at all. The last ;; in the case construct is optional.

@OP: To which if does the fi on line 62 correspond?
These 2 Users Gave Thanks to elixir_sinari For This Post:
# 4  
Old 11-17-2012
SOLVED

Quote:
Originally Posted by elixir_sinari
That should not be a problem at all. The last ;; in the case construct is optional.

@OP: To which if does the fi on line 62 correspond?
yeah its not the ;; in the case, it's not required at the end of the case statement (although it isn't a bad habit). it IS required for multiple case statements. And as far as the fi on line 62, I was just reviewing my code, and it was one of those things that I just kept looking over and I noticed. I got on here to post this as resolved. The fi was a mistake due to the copy and pasting from the other scenario of the game. I know copy/paste causes a lot of errors and I browsed it for misplaced quotation marks and various other errors, but I forgot that the whole statement that I copied was part of an if statement from the other scenario. That fi on line 62 should not have been there, there only should have been the one on line 60 but thank you so much for your prompt response to this. I've just began learning scripting and bash as a whole about 4 days ago, so I'm sure this is going to be a go-to source for help in this text based game. I'm just trying to find a way to spice it up and once I do I'm sure I'll have way more complicate code than [ICODE]case[/ICODE[, while/do and nested if statements!!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating a text based game using shell script.

Hello guys I'm new to shell scripting and I need to make a game using shell script. I want to know if it is possible for me a total noob to shell scripting to make this game. The game concept is simple: First thing when you launch the script you get a menu in which you select if you want to... (3 Replies)
Discussion started by: Othmane
3 Replies

2. UNIX for Dummies Questions & Answers

[Solved] Making a text based game

Hello, I am looking to make a text based game, that runs in the command window, or a window similar. I will only need to use 1 window. I read somewhere that there is libraries for this kind of thing? But I can't remember the name of them.. Can anyone point me in a direction? I will be... (2 Replies)
Discussion started by: murphy
2 Replies

3. Programming

This Makes NO sense. I'm making a game and getting an error, need help.

Okay so I'm making a simple text based game that branches into different scenarios. By branching I mean branching off into whole different files with that part of the game in it. I got tired of working on scenario 1 so I'm working on scenario 2. As I get started and try to test it, I get an error... (1 Reply)
Discussion started by: lemonoid
1 Replies

4. Shell Programming and Scripting

Making a Text based game. Need help.

Okay so Zork sparked my interest in this. I have been learning to program for the last year and a half. I've dabbled in everything from Java to Ruby to PHP & XHTML & SQL, and now I'm on bash. I really like bash scripting. Its easy and fun. I just started two days ago. Pretty much I've been writing... (1 Reply)
Discussion started by: lemonoid
1 Replies

5. UNIX for Dummies Questions & Answers

text based football game?

Is there a textbased football game (American) that I can download through ubuntu server edition? (1 Reply)
Discussion started by: dadoprso
1 Replies

6. Shell Programming and Scripting

diff result makes no sense

Hi, I have written a small shellscript Imagine dbalt.txt already existed... " .... touch report.txt lynx -dump "http://site.com/index.htm" > site1.txt lynx -dump "http://site.com/index2.htm" > site2.txt grep -E 'Nummer: |EUR' site1.txt > preis1.txt grep -E 'Nummer: |EUR' site2.txt >... (2 Replies)
Discussion started by: Blackbox
2 Replies

7. Shell Programming and Scripting

BASH: How do I grep on a variable? (or simmilar question that makes sense)

Hi, I've been running code which very frequently calls books.csv. e.g: grep -i horror books.csv > tempExcept, I'm trying to move away from using temporary files or frequently calling books.csv to improve efficiency. So I tried something like bookfile=$(cat books.csv) grep -i horror... (4 Replies)
Discussion started by: Quan
4 Replies

8. UNIX for Dummies Questions & Answers

Simple grep - Not sure it makes sense!

I have 3 files in directory mydir named as follows, I run the sequence of commands shown below and I have questions at the result. File names are: ABC_GP0 ABC_GP0.ctl ABC_GPX Commands and results: $ ls /mydir/ | grep * <-- (q1) I get nothing - OK $ ls /mydir/ | grep... (5 Replies)
Discussion started by: GNMIKE
5 Replies

9. Linux Benchmarks

Linux Benchmarks Makes No Sense

I created two computers with identical hardware, and run the benchmark programs in both starting at the same exact time. What makes no sense is that the computer that has the lower average index (121) finished the race a good 30 minutes ahead of the computer wich showed the higher avg index... (0 Replies)
Discussion started by: philip_38
0 Replies
Login or Register to Ask a Question