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 — 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
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