I think this assignment was a great idea. It allows the students to add input into what they think this course should cover. For this assignment, I chose to have the reader write a bash script file. Scripting is an important tool that Linux provides. It allows you to execute lines of code without you having to type all of them in. It also allows for conditional statements to change what will execute.
In my assignment, I had the reader create a bash script to check for changes on a website. This would be particularly useful when checking for some sort of update. For instance, if you want to see if VT has canceled class and don’t want to check the website continuously, you could use this script. The assignment that I created specifies that the bash script do the following in an infinite loop:
- Download an html web page
- Wait some amount of time
- Download the same html webpage
- Display the differences between the two files
In the finish script, I ended up using:
While working on the final script, I found it easier to remove all of the html tags with:
sed –e :a –e ‘s/<[^>]*>//g;/</N;//ba’
Then I would use diff and pipe that to another sed command to get the formatting I wanted.
Throughout the completion of the assignment, it forced me to gain a more in depth experience with mostly sed.
Our final project has reached completion. Everything works, the only thing left to do is to play the game for hours on end and try to produce errors, as well as catch spelling mistakes and proper spacing. Since the last post, a great deal of thought went into considering the fighting style of the game. We ended up implementing a Pokémon style, where you take turns with the zombie hitting each other. The player has a plethora of weapons that are obtained thought their navigation of the game. Ammo will be limited and an infinite use knife will be provided at the beginning of the game. The fights also have random components like weapon accuracy and chance of running into a zombie.
It is also worth mentioning the save and load game functions. They both extensively used python’s pickle module. It is used for object serialization. It can dump and load variables to/from files. To see more about this module, you can check it out here.
In all, this project has extensively used python’s dictionaries to store all the needed data. Even our list of available actions is stored in a dictionary. Needless to say, this project has given me greater insight into dictionaries, even more so than Homework 4 did, which dealt with maintaining an inventory of parts.
We have decided to make each room a folder. However, instead of having folders in folders for our room layout, we will have all the room folders in one subdirectory. We have also decided to use multiple files in each folder for the different actions to use. We have split the project up amongst ourselves. Two people will be coding in python and two people will write the room descriptions, action files, etc. We already have a basic implementation of the project, all we need to do is add some actions, add the room descriptions, and action files.
In the past two weeks, I have met with my final project group twice. We have decided to create a text based adventure game for The Walking Dead. The structure of the game will be based on the Linux filesystem. Each folder will be its own room, with the different directions you can move. For instance the parent folder will go back and child folders to go left/right. Items and other actions will be additional files is the folders. Instead of having the entire game text be in the main python program, we have decided to break it up. We have come up with two ways to do this.
- The room description and items have their own text file that the python script will read from. In this case, the program would only need to know its folder location and any items picked up. This would make it easy to create a save game addition.
- Every folder has its own python script. In this case, the program would only know the folder location and to call the python script of the folder and wait. The folder python script would contain the room description as well as all actions and items. This would make saving the game be more difficult and would add complexity in keeping the inventory from room to room.
Both cases have different complexities, however, I personally think that case 1 would be the more elegant way to implement the idea.
If anyone has another idea on implementation, feel free to comment.
After completing the practice midterm exam, I felt pretty confident going into the actual exam. The questions on the exam were pretty straight forward and somewhat challenging. However, one of the scripts that was supposed to record entries in the terminal did not work. I decided I was wasting too much time messing around with it and decided to leave it as is. Also, one of the questions asks you to correct some mistakes in a program. There was no description of what the program was supposed to do and took extra time to determine if the program was functioning correctly or just functioning. Overall, the exam ended up frustrating me and taking much longer than it should have.
Homework 4 turned out to be a little more confusing than anticipated. It was the first time using a data structure rather than just a variable. The requirement of the assignment was to write a python script that would take in an inventory file and manipulate the data based on commands provided through standard in. In the description, the instructor provided some tips on using dictionaries. I could not comprehend how to successfully implement a dictionary for the assignment. I ended up just thinking about the assignment as if I were doing it in c++. Instead of the dictionary, I ended up using a 2D list. I am sure that if a dictionary was implemented, the assignment would have been much easier. As for the manipulation part of the assignment, everything was pretty straight forward. The main problems I had, were that “Quantity” was an int, and it would need its own if statements to account for that. Also, when writing the sort function, I had to learn about key=lambda.
These past two weeks have mostly been looking at our last and next python assignments. The last homework looked like it was going to be quite difficult. However, after starting the homework, I realized that pretty much everything I needed to know was in the assignment description. The links to other websites with examples helped out a tremendous amount when it came to argparse. If I was not told about argparse, I am sure the homework would have taken twice as long. The next homework that is due seems even more complex. I am just glad for the high level of detail in the description as well as a blog post by the instructor on how to achieve certain actions that the program must do. The main issue I have seen so far in class is the lack of time. It seems like once you just start understanding something, class is over and the next class is on a completely different topic.
This week, we learned a little more about the UNIX file system. The file system is similar to that of any other major operating system. There are some exceptions however. For instance, instead of having multiple drives (ie. C:\, D:\), everything is located under the root directory (/) as seen below. All other devices (disk drive, etc.) are located under /dev.
One very important command to keep in mind is chmod or change mode. This command allows you to change the permissions of files and directories. I decided to do a little more exploring of the command. While searching, I came across a list of common chmod combinations (below) here.
|chmod 400 file
||To protect a file against accidental overwriting.
|chmod 500 directory
||To protect yourself from accidentally removing, renaming or moving files from this directory.
|chmod 600 file
||A private file only changeable by the user who entered this command.
|chmod 644 file
||A publicly readable file that can only be changed by the issuing user.
|chmod 660 file
||Users belonging to your group can change this files, others don’t have any access to it at all.
|chmod 700 file
||Protects a file against any access from other users, while the issuing user still has full access.
|chmod 755 directory
||For files that should be readable and executable by others, but only changeable by the issuing user.
|chmod 775 file
||Standard file sharing mode for a group.
|chmod 777 file
||Everybody can do everything to this file.
|chmod +x file
||Enables only the file execution.
Basic Shell Commands
This week in ECE 2524, we took a look at some of the basic shell commands listed below.
The exercise was pretty straight forward. As a small group, we divided the commands for each person to research. For each of our commands, we had to find the usage of the command, common flags and options, and some examples. In my opinion, the exercise would have been more helpful if after we discussed our commands, we had an exercise where we would have to use some or most of the commands. However, overall the exercise was a good learning exercise.
We have been following along with an online book, Learn Python the Hard Way, that will teach us how to program in python. I have made it through exercise 9, and so far it has been very helpful. I have quite a bit of experience in various other languages, and this book helps me see the connection Python has with them. I look forward to going through the rest of the book.
First, I would like to state that Ubuntu is not the first Linux operating system (OS) I have used. I do have some experience with different versions of BackTrack (BT). Before installing Ubuntu 12.04 LTS, I considered learning BT more in-depth for a class I am taking at Virginia Tech (Intro to Unix for Engineers). However, after installing Ubuntu I decided to stick with it. This was mainly due to the fact that Ubuntu, for me, is a more well designed, well rounded OS. BT is geared more towards the computer security workforce, whereas Ubuntu is more of an Average Joe’s OS.
After booting into Ubuntu, you come to a beautiful login screen. After typing in my password and pressing enter, my desktop seamlessly pops right up. No wait text with a circle next to it, no black transition screen, and no lag to start up a program. The first thing I notice are all the essential programs are installed by default. Programs similar to Microsoft Word, Excel, Power Point, ect are already installed and on your dock.
Some things worth mentioning:
- Even if you don’t like to write command lines, Ubuntu is still an excellent Windows / iOS alternative.
- Any program you could possibly want is probably located in the Package Manager (similar to an app store but for programs and more). Which means less time searching for programs and you have one place to go to update all your software.
- Most viruses are designed to attack Windows machines. Avoid viruses be switching to Linux.