User Tools

Site Tools


opus:fall2011:lgottsha:part2

Part 2

Entries

October 4th, 2011

Today we played with regular expressions in class and used them to sort through the dictionary. We learned regular expressions are helpful in finding things when you don't know exactly what you're looking for or don't know all of what your looking for.

October 6th, 2011

Today we learned more regular expressions and were given time to play. Haas helped me figure out how to do the basics of my Spambot idea so he can now scream at anyone who talks to him ^.^

October 13th, 2011

Today we played a bit with C programming after a conversation about the death of bills gates vs. the death of the producer of C. We wrote a script in C and then made the same script in Bash.

October 27th,2011

Today we had playtime to protest the cursed snow that has arrived early. I spent some time working on my bot.

unix Topics

Text Processing

Text Processing is the simple act of typing in a text editor. Unix has two main text editors. Nano, and VI. It's a lot like wordpad versus microsoft word. Nano is about as basic as you can get with nothing aside from the ability to enter text and save text files. VI, the “greatest text editor” ever however comes with a whole bunch of useful commands that allow you to edit your text in it's command mode, as well as an insert mode that allows you to simply edit text.

Compression/Decompression

Compressing a file reduces it's size but makes it completely unacessable until it's Decompressed. The compression command for a file is gzip while the command to Decompress it gunzip. An example is shown below.

lab46:~$ ls
Datatypes.c  Hello.s  bin         data       dl     irc      motd     tmp
Downloads    Maildir  closet      datatyes   hello  link     scripts  uhoh
Hello.c      bashex   cscript2.c  datatypes  in     longcat  src
lab46:~$ gziplongcat
-bash: gziplongcat: command not found
lab46:~$ gzip longcat
lab46:~$ ls
Datatypes.c  Hello.s  bin         data       dl     irc         motd     tmp
Downloads    Maildir  closet      datatyes   hello  link        scripts  uhoh
Hello.c      bashex   cscript2.c  datatypes  in     longcat.gz  src
lab46:~$ gunzip longcat.gz
lab46:~$ ls
Datatypes.c  Hello.s  bin         data       dl     irc      motd     tmp
Downloads    Maildir  closet      datatyes   hello  link     scripts  uhoh
Hello.c      bashex   cscript2.c  datatypes  in     longcat  src

Moving/Renaming

Moving and renaming files are done with the move command mv. To rename a file you simply type mv followed by the filename and new desired name. To move them you type the name of the file followed by the directory you wish to put them in. Examples provided below.

lab46:~$
lab46:~$ ls
Datatypes.c  Hello.s  bin         data       dl     irc      motd     tmp
Downloads    Maildir  closet      datatyes   hello  link     scripts  uhoh
Hello.c      bashex   cscript2.c  datatypes  in     longcat  src
lab46:~$ mv longcat Catgnol
lab46:~$ ls
Catgnol      Hello.c  bashex  cscript2.c  datatypes  in    motd     tmp
Datatypes.c  Hello.s  bin     data        dl         irc   scripts  uhoh
Downloads    Maildir  closet  datatyes    hello      link  src
lab46:~$ mv Catgnol /closet
mv: cannot create regular file `/closet': Permission denied
lab46:~$ mv Catgnol bin
lab46:~$ ls
Datatypes.c  Hello.s  bin         data       dl     irc   scripts  uhoh
Downloads    Maildir  closet      datatyes   hello  link  src
Hello.c      bashex   cscript2.c  datatypes  in     motd  tmp
lab46:~$

Creating Files

There are multiple ways to make files in Unix. You can create it with the Touch command by type “Touch” followed by the filename. You can also create a file using text editors Nano and VI by saving a blank document as the filename. An Example of the Touch Command is shown below.

lab46:~$ ls
Datatypes.c  Hello.s  bin         data       dl     irc   scripts  uhoh
Downloads    Maildir  closet      datatyes   hello  link  src
Hello.c      bashex   cscript2.c  datatypes  in     motd  tmp
lab46:~$ touch AllHallowed
lab46:~$ ls
AllHallowed  Hello.c  bashex  cscript2.c  datatypes  in    motd     tmp
Datatypes.c  Hello.s  bin     data        dl         irc   scripts  uhoh
Downloads    Maildir  closet  datatyes    hello      link  src
lab46:~$


Linking Files

Linking files is done with the ln command. Using ln -s and the filename followed by the linkname to create a link. An example is show below.

lab46:~$ ls
AllHallowed  Hello.c  bashex  cscript2.c  datatypes  in    motd     tmp
Datatypes.c  Hello.s  bin     data        dl         irc   scripts  uhoh
Downloads    Maildir  closet  datatyes    hello      link  src
lab46:~$ ln -s AllHallowed click
lab46:~$ ls
AllHallowed  Hello.c  bashex  closet      datatyes   hello  link     src
Datatypes.c  Hello.s  bin     cscript2.c  datatypes  in     motd     tmp
Downloads    Maildir  click   data        dl         irc    scripts  uhoh
lab46:~$ click
-bash: click: command not found
lab46:~$ cat click
Happy Halloween
lab46:~$

Copying Files

Copying a file just like on a GUI system like windows creates an exact duplicate of the file. Copying is done with the CP command followed by the file you wish to copy and the name of the new file. An example is shown below.

lab46:~/bin$ ls
Binary   Doomsday  Password  Script1.sh  Script3.sh  Script5.sh  Spambot2.0  opusresults
Catgnol  IIRC      Project   Script2.sh  Script4.sh  Spambot     hallow
lab46:~/bin$ cp Password JPRef
lab46:~/bin$ ls
Binary   Doomsday  JPRef     Project     Script2.sh  Script4.sh  Spambot     hallow
Catgnol  IIRC      Password  Script1.sh  Script3.sh  Script5.sh  Spambot2.0  opusresults
lab46:~/bin$ cat Password JPRef
Ah-ah-ah. You didn't say the magic word.

Ah-ah-ah. You didn't say the magic word.

C

C is a programming language that can be found on most computers today. Considered a 'lower' language, C can assume certain things such as using the word add instead of the addition symbol. Below is an example of C code.

#include <stdio.h>

int main() {
    printf("Hello, world!\n");
    return 0;
}

Tab Completion

When typing on Unix, on the command line and then pressing tab after typing a partial command or filename will complete the file name. However if multiple files have the same beginning then you must put enough of the file name to differentiate them or tab complete wont' work.

wildcards

A wild card is used to find part of a file name or find part of a term within a file and can be used to find files when you only have a part of their name or data. An example is shown below.

lab46:/usr$
lab46:/usr$ ls
bin  games  include  lib  lib32  lib64  local  man  sbin  share  src
lab46:/usr$ ls  *[aeiouy]|wc -l
375
lab46:/usr$

375 files end in a vowel within the usr directory

Regular expression

Can be used to find information within files an examples is below

lab46:~$ ls
AllHallowed  Downloads  Hello.s  bashex  closet      data      datatypes  hello  irc   motd     src  uhoh
Datatypes.c  Hello.c    Maildir  bin     cscript2.c  datatyes  dl         in     link  scripts  tmp
lab46:~$ cat Datatypes.c |grep '^[one]*$'|less|wc -l
1
lab46:~$

The Datatypes.c files has exactly one “one” in it.

Local Host

The local host is the host upon which your directly accessing from your location. in the case of our Unix class the local hos would be the Lab46 server.

Remote Hosts

A remote host differs from a local host in that it isn't part of the sever or system that you are on but you can access it. An examples of this would be running a program off of cloud storage.

unix Objective

Objective

Understand the workings of Shell scriptings

Method

Pick apart one of the scripts we do in class and see if i can understand how things work.

Measurement

I was able to understand the basics of how our Binary Number Converter worked.

#!/bin/bash
a=0
echo -n "Please enter a Number: "
read number
until [ $number -eq 0 ]; do
n=0
until [ `echo "$number-2^$n"|bc` -lt 0 ];do
let n=$n+1
done
let n=$n-1
let number=$number-`echo "2^$n"|bc`
places=""
for((i=0;i<$n;i++)); do
places="${places}0"
done
places="1${places}"
let a=$a+$places
done
echo "the binary value is $a"
exit 0
lab46:~/bin$

Analysis

Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.

  • How did you do?
  • Room for improvement?
  • Could the measurement process be enhanced to be more effective?
  • Do you think this enhancement would be efficient to employ?
  • Could the course objective be altered to be more applicable? How would you alter it?

A.I think i did acceptably at it. B.There's always room for improvement. C. Not really. Measuring your understanding can't really be given an exact definition D. Yes because it makes it a bit easier when writing code for scripting E. Not really. Most of it's just experience.

Experiments

Experiment 1

Question

What is the question you'd like to pose for experimentation? State it here.

Resources

Collect information and resources (such as URLs of web resources), and comment on knowledge obtained that you think will provide useful background information to aid in performing the experiment.

Hypothesis

Based on what you've read with respect to your original posed question, what do you think will be the result of your experiment (ie an educated guess based on the facts known). This is done before actually performing the experiment.

State your rationale.

Experiment

How are you going to test your hypothesis? What is the structure of your experiment?

Data

Perform your experiment, and collect/document the results here.

Analysis

Based on the data collected:

  • was your hypothesis correct?
  • was your hypothesis not applicable?
  • is there more going on than you originally thought? (shortcomings in hypothesis)
  • what shortcomings might there be in your experiment?
  • what shortcomings might there be in your data?

Conclusions

What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.

Experiment 2

Question

What is the question you'd like to pose for experimentation? State it here.

Resources

Collect information and resources (such as URLs of web resources), and comment on knowledge obtained that you think will provide useful background information to aid in performing the experiment.

Hypothesis

Based on what you've read with respect to your original posed question, what do you think will be the result of your experiment (ie an educated guess based on the facts known). This is done before actually performing the experiment.

State your rationale.

Experiment

How are you going to test your hypothesis? What is the structure of your experiment?

Data

Perform your experiment, and collect/document the results here.

Analysis

Based on the data collected:

  • was your hypothesis correct?
  • was your hypothesis not applicable?
  • is there more going on than you originally thought? (shortcomings in hypothesis)
  • what shortcomings might there be in your experiment?
  • what shortcomings might there be in your data?

Conclusions

What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.

Retest

If you're doing an experiment instead of a retest, delete this section.

If you've opted to test the experiment of someone else, delete the experiment section and steps above; perform the following steps:

State Experiment

Whose existing experiment are you going to retest? Prove the URL, note the author, and restate their question.

Resources

Evaluate their resources and commentary. Answer the following questions:

  • Do you feel the given resources are adequate in providing sufficient background information?
  • Are there additional resources you've found that you can add to the resources list?
  • Does the original experimenter appear to have obtained a necessary fundamental understanding of the concepts leading up to their stated experiment?
  • If you find a deviation in opinion, state why you think this might exist.

Hypothesis

State their experiment's hypothesis. Answer the following questions:

  • Do you feel their hypothesis is adequate in capturing the essence of what they're trying to discover?
  • What improvements could you make to their hypothesis, if any?

Experiment

Follow the steps given to recreate the original experiment. Answer the following questions:

  • Are the instructions correct in successfully achieving the results?
  • Is there room for improvement in the experiment instructions/description? What suggestions would you make?
  • Would you make any alterations to the structure of the experiment to yield better results? What, and why?

Data

Publish the data you have gained from your performing of the experiment here.

Analysis

Answer the following:

  • Does the data seem in-line with the published data from the original author?
  • Can you explain any deviations?
  • How about any sources of error?
  • Is the stated hypothesis adequate?

Conclusions

Answer the following:

  • What conclusions can you make based on performing the experiment?
  • Do you feel the experiment was adequate in obtaining a further understanding of a concept?
  • Does the original author appear to have gotten some value out of performing the experiment?
  • Any suggestions or observations that could improve this particular process (in general, or specifically you, or specifically for the original author).
opus/fall2011/lgottsha/part2.txt · Last modified: 2011/11/01 00:36 by lgottsha