Final project

 

Team Dynamic that consist of Steven Paredes, Jose Rodriguez, Lely Estevez, Dharam Deojah. We decide to build a webcam server which would stream a video using usb webcam connect to a raspberry pi. The project was a fail so we decided to do a webserver using apache, which is a webserver application that help to deliver web content to be access though the internet. We first had to configure the operating system in the raspberry pi and basic setup which is $sudo apt-get update a command that is used to update the repository of the raspberry pi. When the update was completed we wanted to use the raspberry pi on our laptop so we download putty which is a software that let you access ssh servers if you know the credentials. Then we went ahead with the software installation commands used will be at the end of the project.  We had to change a couple of .conf files with nano which is a text editor. The installation of the apache server was completed, but we wanted to make the site better looking, so in order change the content of the webserver we have to set up an ftp server and change the ownership of www server directory. After that we had to install vsftpd which is an ftp server for UNIX base systems. The follow step involved making the ftp folder equal to our website server folder but in order to do this we need login in as root. After we set up the ftp server we were able to start up an ftp client with this program called winSCP which allows access to our www server files to edit the site.

Setup the website was so exciting so many idea came running though my head but I needed to keep it simple and something that would work to I went on youtube to lead basic HTML programming skills to create a page. The end product of our site is a page that displays a message and then tells you to write your name, the message then add the user name displaying” hi username! Welcome to the best page ever”. Also the website contains two popular search engine Google and Bing so if the user need to leave the page they can just click on the link instead of going to the address bar and typing it in. Last minute adds to the website added a Celsius to Fahrenheit converter as well as a time display. The website also includes links for user who visit the website. I actually learn I lot during this project, learn a little Html, power of the raspberry pi and networking problem and solutions. We couldn’t host the website on the raspberry pi so instead we hosted a domain and copied the HTML file.

Ps www.emt2390l.comlu.com to check out the website.

 

Steven Paredes

  • Edited the website and also configured the raspberry pi. I supplied the Usb hub and the vga to hdmi converter. As well as worked with the raspberry pi and also finish three other projects( a script that allows a user to take a picture with a webcam, I setup a own cloud which is basically like drop box except it not, the web server and the hangman game

Jose Rodriguez

  • Assisted me with help when I was struggling setup the internet on pi he manage to allow his computer to give the internet to the pi. Also helped me by encouraging me and being dj while we work on the project.

Lely Estevez

  • helped technical suggestion for how to connect the pi and configuring it. Also assisted in troubleshooting all of the projects we worked on the web server, webcam, and hangman games script

Dharam Deoraj

  • Work on the hangman game on the terminal which I hope is a get success he also help my when I was editing the html files. He also assisted in the Celsius to Fahrenheit script and cleaned up my html file.
 <html>
<head>
<title> EMT2390L &mdash; Final Project </title>
<link rel=”stylesheet” type=”text/css” href=”style.css” />
<script>
function clicked() {
var x;
x = document.getElementById(‘nameCheck’).value;
if (x != “”) {
document.getElementById(‘greeting’).innerHTML = ‘Hi, ‘ + x + ‘! Welcome to my site!’;
} else {
document.getElementById(‘errorMsg’).innerHTML = ‘<font color=”red”>(required) Name:</font>’;
}
}
function convert(degree) {
if (degree == “C”)
{
F = document.getElementById(“c”).value * 9 / 5 + 32;
document.getElementById(“f”).value = Math.round(F);
}
else
{
C = (document.getElementById(“f”).value -32) * 5 / 9;
document.getElementById(“c”).value = Math.round(C);
}
}
</script>
</head>
<body>
<div class=”main”>
<table border=”0″ cellspacing=”25″ cellpadding=”10″ width=”100%” bgcolor=”251111″ <!–Used to adjust the length of the tables–>
<div class=”row1″>
<img src=”http://upload.wikimedia.org/wikipedia/commons/f/f3/Santa_Claus_icon.png” />
</div>
<div class=”row2″>
<div class=”row2col1″>
<p>Search Engine’s</p>
<ul>
<li><a style=text-decoration:none href=”http://www.bing.com/“>BING</a>
</li>
<li><a style=text-decoration:none href=”https://www.google.com/“>GOOGLE</a>
</li>
</ul>
<div>
<div class=”row2col2″>
<p class=”welcome” id=”greeting”>
Hi! Welcome to the best site
<form>
<b id=”errorMsg”>Name:</b>
<input type=”text” id=”nameCheck” />
<input type=”button” value=”Click Me” onClick=”clicked()” />
</form>
</p>
<p class=”content”>
Welcome to my page! This page created for my operating system class using a Raspberry pi. This semester was fun and but it time to go on vacation merry christmas.
</p>
</div>
</div>
<hr align=”left” width=75%>
<div>
<div class=”row2col2″>
<p class=”welcome” id=”greeting”>
Convert Celcuis to Fahrenheit
<form>
<input id=”c” onkeyup=”convert(‘C’)”>Degrees Celsius</input>
<br />
<input id=”f” onkeyup=”convert(‘F’)”>Degrees Fahrenheit</input>
</form>
</p>
</div>
<h1>Time and Date</h1>
<button type=”button”
onclick=”document.getElementById(‘time’).innerHTML = Date()”>
Click me to display Date and Time.</button>
<p id=”time”></p> </div>
</table>
<hr align=”left” width=75%>
<h4><p>For more information about the people who created this page please go to the links below </p></h4>
<li>
<p> Steven Paredes </p>
</li>
<p> <a href=”https://www.facebook.com/steven.paredes.9“>Follow me on Facebook</a>
</p>
<p><a href=”http://instagram.com/lokoto5000/“>Instagram</a> </p>
<li>
<p> Jose Rodriguez </p>
</li>
<p> <a href=”https://www.facebook.com/profile.php?id=100001105402470&fref=ts“>Follow me on Facebook</a>
<p><a href=”http://instagram.com/joselitofrod“>Instagram</a> </p>
</p>
<li>
<p> Lely Estevez </p>
</li>
<p> <a href=”https://www.facebook.com/wilson.estevez.37?fref=ts“>Follow me on Facebook</a>
</p>
<li>
<p> Dharam Deoraj </p>
</li>
<p> <a href=”https://www.facebook.com/jdeooo?fref=ts“>Follow me on Facebook</a>
<p><a href=”http://instagram.com/cxke.s“>Instagram</a></p>
</p>
</ul>
</h4>
</body>
</html>

 

Final product running

2014-12-13_18-42-05

 

 

Project #2: Hangbash

Along with our Raspberry Pi Web Server, we decided to create a simple script-based game that can played via the Terminal. This game combines a few of the commands we’ve learned throughout the semester, and a few new commands that we had to look up in order to understand. Such as sed and wc. However, these commands helped us achieve our goal in creating our own Hangman game, which we decided to call Hangbash. We had to make sure that   the script is able to be executed. Terminal will not allow the script to run by default, it will not be able to do so. We can correct this by using the command: chmod u+rwx hangbash.sh, the same command will need to be used for the other public script used in tandem with our project: chmod u+rwx randomquote.sh. The script allows us to pick a random string from a file that has strings separated on a one-per-line basis. The chmod u+rwx command allows the selected script to read, write and execute under the current user.

 

When creating Hangbash. One issue were having was that we couldn’t get our main script to load the two external files needed for our game. One being the list of words used for Hangbash, and the other being the public script used for randomly selecting a word. In Unix systems, the pwd command can be used for printing the working directory. By using PWD=$(pwd) in our script, we assigned the variable PWD to be the working directory. Later in the script, we wrote down the locations of the two external files like so: wordLibrary=”$PWD/hangbash/wordLib.txt” and randomWord=”$PWD/hangbash/randomquote.sh”. The variable wordLibrary would be used to locate the text file containing all of the words usable for this game. This library can of course, be changed and/or edited as the user of the game pleases. The randomWord variable uses the randomquote.sh script to pick a random word out of the wordLib.txt file. When the game is loaded into the terminal via ./hangbash.sh, it will display the startup screen. It will then check an if statement to see whether or not the wordLibrary.txt is valid and useable, and then begins the game. When a user is playing the game, they have a predetermined amount of chances (10 during our testing phase) to guess the correct letters for the word. At this time, no hints are given to what they word may be, except for the number of letters in the word (displayed by hyphens; see screenshots at the end). When the user guesses a letter, it has to be lower case, cannot be previously guessed, and cannot be a number. Conditions were put in place to check our users input, compare it to a subset of strings and see whether or not it’s valid. Upon entering a valid guess, another Conditional will be checked to see whether or not the word contains that letter. If it does contain the letter, the game will alert you, and repeat the loop for more inputs. If it doesn’t contain the letter, you will lose one guess, and be prompted to guess again. If you guess wrong 10 times, you lose. Upon winning or losing, the game will also prompt you with how many times you’ve won and how many times you’ve lost. This was a simple feature added so we could support simple score keeping. if the users types in “quit”, the game end, and the script will exit.

Team Contributions:

  • Dharam Deoraj
    • He was responsible for writing majority of the script that was used in order to run the game. Alongside writing the initial code, he also commented each section of the code so that my teammates and future readers could easily understand the logic behind the script.
  • Lely Estevez
    • Lely was responsible for finding a list of words for the game to use. He also double checked the initial code that was written to see if there were any immediate mistakes that were lying around. There were a few that he found, such as simple spelling mistakes, and spaces between parameters for commands used in the Conditional statements.
  • Steven Paredes & Jose Rodriguez
    • Me and Jose played an important part in the creation of our game. Once Lely and Dharam finished finding any initial errors in the script, Steven and Jose were the ones who needed to play the game and use all of the options in order to make sure everything worked correctly. After a few sessions of testing the games, they realized that the “quit” feature was not working due to a variable being incorrectly referenced inside of the code.

 

 

 

Hangbash Script:

#!/bin/bash

#BASH adaptation for ‘Hangman’. There will not be a image displayed for
#the hanging man. A variable will be keeping track of how many incorrect
#guesses are made whilst playing.

PWD=$(pwd) #Get the working directory so we can load our files.
wordLibrary=”$PWD/hangbash/wordLib.txt” #Our list of words.
randomWord=”$PWD/hangbash/randomquote.sh” #Randomization script used from ‘Wicked Cool Shell Scripts’.
null_str=”\.” #Used for the sed [set] when $guessedLetter is empty.
gamesPlayed=0 #Total amount of games that the user has played.
gamesWon=0 #Total amount of games that the user has won.
gamesLost=0 #Total amount of games that the user has lost.
userGuess=”” #Variable for storing the guessed letter the user entered.
guessed=”” #Variable for comparison of the guessed letter.

echo ” _____ _____ _____ _____ _____ _____ _____ _____ ”
echo “| | | _ | | | __| __ | _ | __| | |”
echo “| | | | | | | | __ -| |__ | |”
echo “|__|__|__|__|_|___|_____|_____|__|__|_____|__|__|”
echo “————————————————-”
echo “————EMT 2390L – FINAL PROJECT————”

if [ ! -r $wordLibrary ] ; then #Check if the wordLib.txt is readable (exists)
echo “$0: Unable to find wordLib.txt. ”
echo “You can create your own wordLib.txt and place it inside of the ”
echo “/hangbash/ folder. Once a wordLib.txt is placed there, you can play.”
exit 1
fi

while [ “$userGuess” != “quit” ] ; do #Runs the game as long as they don’t type “quit”
match=”$($randomWord $wordLibrary)” #Choose a random word from the wordLibrary
if [ $gamesPlayed -gt 0 ] ; then #Print the new game alert
echo “~~~ New Game Started ~~~”
guessed=””
userGuess=””
fi

gamesPlayed=”$(($gamesPlayed + 1))” #Incriment gamesPlayed by 1 each time
badGuessCount=${1:-10}
partialWord=”$(echo $match | sed “s/[^$null_str${guessed}]/-/g”)”
echo
while [ “$userGuess” != “$match” -a “$userGuess” != “quit” ] ; do #Runs the game as long as the user doesn’t enter quit.
if [ ! -z “$guessed” ] ; then
echo -n “Guessed: $guessed, ”
fi

echo “Remaining tries: $badGuessCount, Current word: $partialWord” #Displays your current remaining guesses and how
echo -n “Guess A Letter: ” #much of the word you have guessed.
read userGuess

if [ “$userGuess” = “$match” ] ; then
echo “Congrats! You got it!”
elif [ “$userGuess” = “quit” ] ; then
sleep 0 #NOP; Prevent the program from erroring during the quit.
elif [ $(echo $userGuess | wc -c | sed ‘s/[^:digit:]]//g’) -ne 2 ] ; then #Make sure that they only entered one letter as a guess.
echo “You can only guess one leter at a time! :(”
elif [ ! -z “$(echo $userGuess | sed ‘s/[[:lower:]]//g’)” ] ; then #Make sure that only lowercase letters are entered.
echo “All guesses must be lowercase letters. :(”
elif [ -z “$(echo $userGuess | sed “s/$userGuess$guessed]//g”)” ] ; then #Make sure no duplicates have been entered.
echo “You’ve already tried this letter as a guess! :(”
elif [ “$(echo $match | sed “s/$userGuess/-/g”)” != “$match” ] ; then #If the above conditions are met, it’ll check if
guessed=”$guessed$userGuess” #the letter is part of the word.
partialWord=”$(echo $match | sed “s/[^$null_str${guessed}]/-/g”)”
if [ “$partialWord” = “$match” ] ; then
echo “Congratulations! The word was: \”$match\”.” #The letter is part of the word.
userGuess=”$match” #The enter word has been guessed, so you win.
gamesWon=$(($gamesWon + 1)) #Report back how many times you’ve won the game.
echo “You’ve won $gamesWon games!”
echo “You’ve lost $gamesLost games!”
else
echo “~~~ The letter you guessed, \”$userGuess\” is in the word! ~~~” #The letter is in the word, but you are not finished.
fi
elif [ $badGuessCount -eq 1 ] ; then
echo “~~~ DUN, DUN, DUN! You’ve run out of guesses! :’-( ~~~” #End the game if you run out of guesses, then reset the count.
echo “~~~ The word you were trying to guess was \”$match\” ~~~”
userGuess=”$match”
gamesLost=$(($gamesLost + 1)) #Report back how many times you’ve lost the game.
echo “You’ve lost $gamesLost games!”
echo “You’ve won $gamesWon games!”
else
echo “~~~ Too bad, \”$userGuess\” is not part of the word. ~~~” #If none of the above conditions are met, and your letter is not
guessed=”$guessed$userGuess” #part of the word, you lose one guess, and the loop repeats.
badGuessCount=$(($badGuessCount – 1))
fi
done
done
exit 0

 

SCRIPT

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *