Project

In this final project we have a group of four people which is consist of Jose Rodriguez, Steven Paredes, Lely Estevez and Dharam Deojah. We deicded to do two different projects one is webserver apache which means is a webserver application that delivers web content through its user that can be access on the internet. The second project is a simple game that can be run through via the terminal. Before we decide on the project we actually work on doing a webcam by using the raspberry pi it work in a way because when we put the ip address for the command line it work but showing the actual video from the webcam was the problem. In this project for the webserver we had to configure the raspberry pi’s operating system but using the command $sudo apt-get update. Once the update was done we downloaded putty on our laptops by using the raspberry pi; putty is a software which lets us use the ssh server. Then we started using the commands that can help us installed a software. Throughout this project we did had to change some files with text editor. Then after we finish the apache server installation we decided to try and make the website look more presentable. The way how we did that was to start off by changing the ownership of www server then we install vsftpd which ftp server is a unix base also making the ftp folder the same as the webservers to do that we had to log in  as the root. After we set that up we had install another program called winSCP that helps us to access our server file to remold the site.

Remolding the website was pretty much our personal creation as much we would love to do something amazing and creative we didn’t want to overdo it because we still had to do the second project. We have to give the credit to youtube for this because it gave us instruction on how to do the simplest HTML programing skills to make the page better. The page displays a simple message just write your name to add the name to so say “hi (name type) welcome to the best page ever” credit for headline would go to Steven. This website contains search engine google and bing so if the user want to leave the site he can click that. In this site we also have links for others who visited this site. This project was pretty fun made us communicate more as a group and rely more our open resource then just have a random person doing it for us without understand it.

Team information:

Steven Paredes-  He configure the raspberry pi and also edited out the website. Steven also supplied with usb hub, vga to hdmi convertor and also experiment this a bit further by doing three more projects that relates to this one .

Jose Rodriguez- I helped out when struggle with some part of the setup by looking something’s over and I supply my laptop that let the raspberry pi to use internet connection.

Lely Estevez- Lely helped trouble shoot the project and experiment with it a few times from here and there to see what else can he add to it.

Dharam Deojah-  Dharam helped out editing the website with some edits also worked on the hangman game on the terminal.

 

Script:

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

 

Screen shot:

final project pic one

Final project 2:

This second project is making a simple script game that can be run from the terminal which the name of this game is what we will soon know to love hangbash. This game is making and the combination of many different commands we learn throughout the semester and also some that we never have seen before. The man who deserves the most credits for the name of this game and also who put the most work in making it is Dharam. First, we made sure that the script can actually be executed, by default the script will not run and the terminal won’t be able to execute the script as well. There is a way to correct the issues of the script by using the command chomd u+rwx hangbah.sh.  This same script will be used for another script which is also used to tandem for the project which the command we use is chmond u+rwx randomquote.sh. The script helps us choose a random string from a file that contains a string which is in the basis of one per line. The command chmod u+rwx allow the script selected to read write and execute.

While developing this game and great creature runs into some problem the problem with hangbash is wouldn’t load the main script of the two files in the game. Which is the list of word used for the game and the other is being the public script that selected the words at random. It was hard to determine if it would be naturally would load an external file that can start the directory. So the head created (Dharam) of this game let us know that we won’t follow that   and tried to make it simple to make the file easier to reach.  In the unix system one of the commands we learn in the beginning of this class pwd command can print the work of directory. By adding the PWD=$(pwd) to the script we have assigned a variable and that to be the working directory also later on in the script something else has been added which the location of the external file. There is another variable called wordLibrary which locates the word file and the library can be change. The other variable randomWord uses the randomquote.sh to randomly select a word out of the library text file. When start up the hangbash game it displays ASCII art message then it will check the if statement to see if the library text file can or cannot be used and that when we start. As in a similar game we know you get a certain amount of chance and you won’t receive hint but the number of letter that the word itself has. When playing this game the user can’t use upper case letter nor a number if u do it will not be read once the condition is met then it will look around the other string to see the letter is in the word or not. If it contains the letter the game will alert if it doesn’t you will lose a chance; this game can also keep score on your wins and losses. Finally, to exit the game the player simply type quit and the game would be existed.

 

Team information:

Dharam Deoraj:  Dharam is the head created of this game which he did the majority of the script and also write comments on the side throughout the script so if the user wants make changes the comments would help him guide him through it.

Lely Estevez: Lely was responsible to make and compile the list of words in order to be used in this game he also was the person who went over the script checking for grammar error also extensive use on space and so much more before testing which he found small errors from here and there.

Steven Paredes & Jose Rodriguez: well me and steven we had the most interesting part of this project we are the tester for this game we created and see if all the statements and options are going smoothly to see and also to see if quit works in the game as well.

 

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 emtpy.
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

 

Screen shot of hangbash:

fp1

fp2

fp3