User Tools

Site Tools


opus:fall2011:swilli31:part2

Part 2

Entries

October 4, 2011

Today we went over regular expressions in class. We reviewed and played with basic regular expressions that one may encounter. I am starting to get a good feel for the regular expressions and with a little more practice, I should be fairly comfortable with using them. The biggest difficulty i can foresee with this is knowing precisely what I want to do with them but this is common for all new tools.

October 13, 2011

Today we looked a little bit at C programming. Although we do not need to know much detail about the C language, I found today's lecture quite useful. I vaguely remember doing something in C about 4 years ago for another class but had all but forgotten what I learned. The class today reawakened some of those memories and I remember, at the very least, what some of the symbols and syntax means.

October 18, 2011

Today we talke a little about wildcards and how to use them. I had read about them in in one of the books but had not played with them on my own. Today's class allowed me to see them in action. I see that they are very similar to regular expressions but with minor differences. The same basic principles applied to regular expressions can be applied to wildcards keeping in mind what symbols are used for what and when they can be used appropriatetly.

OCtober 27, 2011

Today I completed the archive handling project. It was a bit of a challenge for me due to the fact that I had not fully read beforhand anything related to archiving. Now that the project is completed, I have a little better of a grasp on archives but am not completely comfortable with them. This can be remedied by more playing and reading.

unix Topics

Regular expression

This allows for shortcuts to be taken when trying to specify what is wanted when searching for something specific in a file.

lab46:/usr/share/dict$ cat words|grep '^[aeiouy]*$'|less|wc -l
15

This shows that there are 15 words in the dictionary file that contain 0 or more of the letters enclosed in the brackets.

Copying

Copying a file is creating an exact replica of a file to another location

lab46:~$ cd /usr
lab46:/usr$ cp -R games /home/swilli31/games
lab46:/usr$

This command copied the games directory into my home directory while still preserving the games directory in the /usr directory.

Moving/Renaming

You can move a file to a diffrent location by using the move command. You can also change the name of a file without losing data by using the move command.

lab46:~$ touch script7
lab46:~$ mv script7 opus.results.sh
lab46:~$

This shows that the file script7 was renamed as opus.results.sh

lab46:~$ mv script7 bin
lab46:~$

This shows that script7 was moved to bin directory.

VI insert mode

The insert mode in vi allows the user to input text or write scripts in the vi editor.

lab46:~$ vi space ghost
~
~
~
~
~
~
~
~
~
~
INSERT

To enter insert mode press i while in command mode.

VI command mode

This mode allows for keys to be used to move the cursor quickly around the screen for easy access to quick edits to the text

~
~
~
~
~
~
~
vi space ghost

To get from insert mode to command mode press the ESC key

VI extended command mode

The extended command mode allows for the user to save and quit the vi editor

~
~
~
~
~
:q!

To enter extended command mode, press the : key. The command shown is quit without saving.

Wildcards

Another form of regular expression that is used where regular expressions aren't recognized.

lab46:~$ cd /usr/bin
lab46:~/usr/bin$ ls -d *[aeiouy]|wc -l
231

This shows that in the directory /usr/bin has 231 files that end in a,e,i,o,u, or y

Compiler

A compiler takes a program and formats it to be read in machine language and can also make a C program executable in bash.

lab46:~$ cd bin
lab46:~/bin$ gcc -o culpepper command.c
lab46:~/bin$ culpepper
culpepper was called with 1 arguments
argv[0]: culpepper
lab46:~/bin$ 

C

lower level Programming language

#include <stdio.h>
 
int main(int argc, char **argv)
{
    int i
    printf(" %s was called with %d arguments\n," argv[0], argc)
    for (i=1; i<argc; i++)
    {
         printf("argv[%d]: %s\n", i, argv[i]);
    }    
    return(0);
}

This is a C program code.

Creating a file

This is simply making a file and bringing it into existance. This can be done using any text editor of choice or simply by they touch command

lab46:~$ touch robot chicken
lab46:~$ ls
lab46:~$ robot chicken space ghost futurama

The file robot chicken was created and was added in the directory with the other files space ghost and futurama.

Archiving/Unarchiving a file

This is a form of compression. Most commonly a tape archive,tar, is used.

lab46:~$ tar -cf archive6.tar futurama
lab46:~$

The archive archive6 was created as a tar file.

Compressing/decompressing a file

This takes a tar file or a zip file and streches it out so that it can be read.

lab46:~$ tar -jcvf archive9.tar.bz2 american horror story
american horror story
lab46:~$ ls
archive6.tar archive9.tar.bz2

The archive9.tar.bz2 was compressed by tar and then compressed to bzip2 format containg the file american horror story.

unix Objective

Objective

Become comfortable with the vi editor

Method

To obtain this objective I will read some material on the vi editor and practice writing scripts

Measurement

After much reading and familiarizing, I am finally able to comfortably write scripts.

Analysis

The vi editor is a useful tool to know and use. Although it is not the only text editor available, it has commands and options that make learning unix easier. My method seems to have been effective due to the fact that I have started dreaming about writing scripts using vi while I slumber.

Experiments

Experiment 1

Question

Can bash handle a multiplication function using decimal and change that number into binary?

Resources

The resources used for this experiment came from other class' notes taken and my previous knowledge about bash. I also tried to combine two scripts previously written

Hypothesis

I will be able to take a number gathered from multiplication.sh and pipe it to script5.

Rationale: The groundwork has been laid it just needs to be written.

Experiment

I will test my hypothesis by writing the new script and running it. The numbers should then be binary

Data

The code is written in binarymultiply.sh. The final output on the screen is below.

lab46:~$ binarymultiply.sh
Please enter multiplicand:5789
Please enter multiplier:22
The product is 127358
The binary value is 11111000101111110
lab46:~$

Analysis

My hypothesis was correct although I could not do it the way I thought I could. I had figured that I could cat in one program to another but because no actual values are stored in either program this created an empty function. The way I fixed this was to set the variable number equal to the product taken from the multiplication and then proceeded to run through the conversion script. It still has the same issues as before in which it doesn't work once the number becomes to large and it no longer out puts to binary.

Conclusions

Based on this experiment there are still some bugs that need to be fixed in converting large numbers into binary as well as multiplying by negative numbers and taking that negative number into a binary value.

Experiment 2

Question

Can I create a dual operating system on my computer with windows and linux?

Resources

I will follow instructions from computer essentials class to download ubuntu and then go from there to create dual OS system.

Hypothesis

I can run my computer with both windows and ubuntu Rationale: The hard drive can be partitioned to handle a dual OS

Experiment

I will test by installing Ubuntu first on a flash drive and then installing to my computer

Data

After a long installation time, I was able to create a dual operating system on my computer. Upon the start I can choose whether or not I wan to run the Windows OS or the Ubuntu OS. The one downside is that files are not shared between the two operating systems.

Analysis

Based on the data collected: My hypothesis was correct but not necessarily applicable. I was able to create a dual OS system but I could also just as easily have overwritten the Windows OS and used Ubuntu solely on its own. A better experiment would be to see if I can transfer files from one OS to another automatically.

Conclusions

I didn't really make any new discoveries nor did I achieve a groundbreaking experiment. I was able to do what I set out to do but not much more than that.

Experiment 3

Does a child process die when the parent is killed?

Resources

This is a look at killing processes and possibly the creation of zombies on the system. The code being used in this experiment was found on http://snippets.dzone.com/posts/show/6233

I also referenced a unix forum on the following website: http://www.unix.com/unix-dummies-questions-answers/100737-how-do-you-create-zombie-process.html

Hypothesis

If the parent process dies, the child will not die with it and become a zombie.

Experiment

I will take the code from the above mentioned website and run it. I will then run the top command to see if there are any zombies in the system

Data

I did not use the code provided on the first resource sit and instead followed the example on the unix forum.

Analysis

I did not follow the experiment the exact was as planned but I was not able to run the check process to see if it actually created a zombie. I did run the top command and there are no zombies reported on the system so my assumption is that I did not successfully create a zombie.

Conclusions

My hypothesis was never tested because I did not create a zombie in the system. If I had a more proven way to create a zombie so that I can at least understand how they work then I may have more to conclude.

opus/fall2011/swilli31/part2.txt · Last modified: 2011/11/01 02:09 by swilli31