Table of Contents

Part 2

Entries

October 6, 2011

This week we learned some new things with regular expressions. Normally we would use a command like cut or grep to pick apart data and choose what we want to show. But with the regular expressions we were able to be even more precise in a more concise manner as well. They are a little hard to grasp because the concepts are kind of obscure, but for the most part i understand how they work. I just need to work with them more in my shell scripting or just in general like in my programs as well. We also did a script that will extract the data from our opus. It takes the total score you can get, the score you got and what percentage you recieve. We wrote that and added more on like cutting off the many decimal points after or similar stuff. We used some regular expressions in it as well which is really confusing but if i pick it apart piece by piece i can understand it. For C i have read more of the book and did a few practice programs from the book and the excercises it gives us. I have yet to start the dataypes project but i should have that done this weekend and i have another idea already for a new project. But other than that, i believe i am getting a grasp on the c language, still a little weird on arrays and calling a function. I understand what they are but i am a little confused on how they work at times but i will get it eventually.

October 13, 2011

This week we did more with regular expressions. We played around with that and used them in a script to become more familiar with them, we also learned wildcards. They are similar to expressions but wildcards are for files, not text. So we can manipulate files with them, not text. we wrote some scripts with the regular expressions in them and we also tried to go through the dictionary finding words only using regular expressions. That was interesting but fun, it made it a lot easier to use when we put it to a simple concept like words in a dictionary. We also just messed around with scripts this week by making one that did binary conversion, it only went to a certain number but it did its job. We learned that linux had its own area for math and it was implemented within the script. In c, i have been reading more of the book however i have not really worked on any projects or exercises. I know i must have 8 or possibly more projects done by the end of the month, i will do my best to finish them. In the meantime, i have been reading and learning however i know i must do some kind of programming to fully reinforce the syntax and logic i must use.

October 20, 2011

This week in linux we played around a little bit with the c language. The class did the first and best program that i will ever write which is the “hello, world” program. It was a simple program but it got the point across on how to write a c language program. then we used linux terminal to compile and execute our programs. After that we got into a little bit more complex programs and played around with them and made our programs work with linux. basically this week was a little introduction to the language for the unix/linux class. For C i have yet to really start anything, i have procrastinated horribly and have not done anything at all this week. I have read when i had time and a little programming aside from the linux class but not enough to truly say i have done work. This coming month i will be sure to get work done.

October 27, 2011

This week was an easy week for classes. This week was catch up on work week, so with the time i had i worked on doing projects. I got up to 4 projects done, one was not documented yet but i will do that once i get the chance. So for the class of unix i have 4 projects and c/c++ i still i have only one done. I really need to get it dont but it is hard with it being online because it constantly sits in the back of my mind and not in the front with the other classes so i become very forgetful, i will step up my game this month and get things done.

cprog Topics

Header Files

header files are files that seperate certain elements from the source code into a reusable file. They contain things like identifiers, classes, subroutines, and other identifiers. A programmer will include this file so that can use standard identifiers to help implement their code easier.

 1 #include <stdio.h>   // This is the header file for the standard library of input and output. So use things like printf and scanf.
  2 #include <math.h>
  3 int main()
  4 {
  5 unsigned short int bob=0;
  6 signed short int jim=0;
  7 printf("before , jim is %hd\n", jim);
  8 jim=pow(2, sizeof(jim)*8);
  9 printf("after, jim is %hd\n", jim);
 10 printf("jim is %d bytes\n", sizeof(jim));
 11 return(0);
 12 }

Pointers

This is a data type that “points” directly to another value stored somewhere in the computer memory using its address. The symbol for a pointer is *. Pointers are simply a indexed array arithmetic, so if you know one it is not too hard to learn the other. here is an example of a pointer:

int a = 5;
int *ptr = NULL;
 
ptr = &a;

This pointer is equal to a null value and points to the address of a.

Multi-Dimensional Array

Multi-dimensional arrays are like arrays within arrays. They have rows and columns with elements to fill them all. You can have a table like structure in it (rectangular to be exact) and pick and choose where to look within the array. you can do this with referenced pointers and thats what would be more commonly used. With this you can put the number of days in a month, all into one place. Below is how it would be shown:

int array2d[ROWS][COLUMNS];

Where the row and column is, thats where you specify your location in the array.

Type Casting

Typecasting is making a variable of one type, such as an int, act like another type, a char, for one single operation. To typecast something, simply put the type of variable you want the actual variable to act as inside parentheses in front of the actual variable. (char)a will make 'a' function as a char.

#include <stdio.h> 

using namespace std;

int main()       
{
  printf (char)65 <<"\n"; 
  // The (char) is a typecast, telling the computer to interpret the 65 as a
  //  character, not as a number.  It is going to give the character output of 
  //  the equivalent of the number 65 (It should be the letter A for ASCII).
  scanf();
}

Selection Structures

The ability to change the flow of program execution. It is achieve by establishing the truth or falsity of an expression (condition). This is done by statements like if, switch or case/file. An if statement asks the user or a process a question of some sort, and it is either the truth or false and depending on where it goes is how the program runs.

This is if:

#include <stdio.h>

int main()
{
  int choice;
  printf("Choose an option: ");
  scanf("%d", &choice);
   if (num > 0) {
    printf("%d is a positive number\n", num);
     if (num % 2 ==0)
       printf("%d is an even number\n", num);
     else
       printf("%d is an odd number\n", num);
     }
   else
     printf("%d is an odd number\n", num);
return(0)
}

This is a sample of an selection statement, other statements like switch have cases and depending on what case is presented, it will choose that case and go through the program.

Compiler

The compiler is a computer programs or a set of programs that transforms source code into object code. The reason for this is because when you write your source code (your syntax language code) it is not executable so in order to make it executable it needs to go through the compiler and make it object code.

Typedef

typedef assigns alternative names to existing types. They most often change the ones that are annoying, long or to make more sense with the implementation. Below is small example of how it could work

typedef int km_per_hour ;
typedef int points ;
 
km_per_hour current_speed ;
points high_score ;
...
 
void congratulate(points your_score) {
    if (your_score > high_score)
...

Enum

Enum is short for enumeration and what it does is instead of having int to represent a set of values, it uses a type of restricted set values instead. Without enum you would have to define each int type specifically with #define then whatever you assign it too. With enum you go like this:

 enum rainbowcolors {
 red,
 orange,
 yellow,
 green, 
 blue,
 indigo,
 violet) 
 }

Then the system will automatically assign a number to each one within the enum but you can set them to whatever you want. Its a easier way to set constants.

Union

A union declaration specifies a set of variable values and a tag naming the union. The variable values are called members of the union and can have different types.

union sign   /* A definition and a declaration */
{
    int svar;
    unsigned uvar;
} number;

This defines a union variable with sign type and declares a variable named number that has two members: svar, a signed integer, and uvar, an unsigned integer. This declaration allows the current value of number to be stored as either a signed or an unsigned value.

Structures

A structure is a collection of variables under a single name. These variables can be of different types, and each has a name which is used to select it from the structure. A structure is a convenient way of grouping several pieces of related information together.

 typedef struct {
          char name[64];
          char course[128];
          int age;
          int year;
  } student;
  
 student st_recc;

This is a structure of variables that is stored into student, which is renamed to st_recc.

Repetition/Iteration Structures

These are similar to the if and switch statements but they are loops. These consist of for, while, and do whiles. A for loop asks for a initialized variable, the parameters of the loop and an incrementation. So with these, the program will run until the parameters are met and it exits out. A while loop goes while a condition is true, and once that condition is untrue it exits out of the loop. A do while does what you want it to do, then checks to see if its true. If the condition is true, the program continues. Its similar to a while loop but with this it executes the program then checks the condition.

Preprocessor

It is a separate program called by the compiler as the first part of translation. The preprocessor handles instructions for the source file inclusion (#include), macro definitions (#define), and conditional inclusion (#if). The language of preprocessor instructions is agnostic to the grammar of C, so the C preprocessor can also be used independently to process other types of files.

unix Topics

$PATH

This is a variable that tells the shell what directory to search for executable files, in response to commands issued by the user. I took a script that was written that has the path “$password” and it uses similar actions as the $PATH variable.

  1 #!/bin/bash
  2 echo -n "Enter magic Password: "
  3 read Password
  4 if [ "$Password" = "`cat pss`" ];  then
  5     echo "Access Granted"
  6 else
  7     echo "access denied"
  8     exit 1
  9 fi
 10 exit 0
 11
lab46:~$ ./soaringeagle1.sh
Enter magic Password: candyland
Access Granted
lab46:~$

Wildcards

Wildcards are basically an indicator to the shell that some particular part of the filename is not known to you and the shell can insert a combination of characters in those places and then work on all the newly formed filenames. Some wildcards that are commonly used are: ? - match any single character * - match 0 or more of anything [] - any one of enclosed [^ ] - not anyone of enclosed

Tab Completion

This is a much faster way then typing out an entire line of commands and files on the command line. Instead of typing out the entire file you can hit “tab” and linux will do its best to finish it for you. So something that could take 5 seconds to type can take 1 second. If it matches 2 or more files you can do a double tab and it will cycle through them.

C

C is a programming language that is a fairly low level-language. Linux is written in this code and you can use linux to create, compile and execute these programs. Just open up a text editor and began typing away your program, assuming you know c language syntax. below is a example of a simple C code used in the VI text editor:

  1 #include <stdio.h>
  2 #include <math.h>
  3 int main()
  4 {
  5 unsigned short int bob=0;
  6 signed short int jim=0;
  7 printf("before , jim is %hd\n", jim);
  8 jim=pow(2, sizeof(jim)*8);
  9 printf("after, jim is %hd\n", jim);
 10 printf("jim is %d bytes\n", sizeof(jim));
 11 return(0);
 12 }
 13

Regular expressions

regular expressions are different ways to manipulate a text. Before we used and piped commands like grep and cut to manipulate our text and get exactly what we wanted. With regular expressions you can manipulate the text to something very precise in a more concise way. Some common regular expressions are:

^ - Match beginning of line
$ - match eof line
. - match any single character
* - match 0 or more of the previous
\< - match beginning of word
\> - match ending of word
[] - match any of what is enclosed
[^] - inverted brackets (do not match..)
() - grouping
| - or
\( \) - grouping for substitution

Killing a Process

When you have a process running in your terminal, whether in the background or foreground, you can easily kill it by using the command kill. There are many kill commands you can use to kill just about anything, as long as you have permission to do so. here is an example of killing another terminal you may have open:

lab46:~$ ps
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
dgirard3 14965  0.0  0.1  13632  2000 pts/40   SNs  00:11   0:00 -bash
dgirard3 25645  0.0  0.1  13624  1944 pts/41   SNs+ 01:00   0:00 -bash
dgirard3 25772  0.0  0.0   8584   972 pts/40   RN+  01:01   0:00 ps u
dgirard3 25993  0.0  0.0  13660     8 pts/33   SNs  Oct13   0:00 /bin/bash
dgirard3 26141  0.0  0.1  42464  1924 pts/33   SN+  Oct13   2:26 irssi
lab46:~$ kill -9 25645
lab46:~$

Now in the other terminal i used a tty command to figure out the PID (process Id) to figure out which process to kill, so when the kill -9 is executed the terminal bash process should quit and it will close out.

Backgrounding a process

When you want to run a command or a process but do not want to clog up the command line while doing so, run it in the background. In order to do this, write the command like you would normally do but this time put a ampersand at the end of it (&). This will put the running process into the background so you can do other things in the foreground. this example shows how the command would be executed by putting into the background, the number shows which process there is in the back so you can have more then one.

lab46:~$ cat hey&
[1] 27455
lab46:~$ #include <stdio.h>

int main()
{
        return(0);
}

Foregrounding a process

This is obviously the opposite to backgrounding but the foreground is where you begin once you bring up the terminal. Where you write and interact with the commands, thats the foreground. But when you background something and want to bring it back, all you have to do is use the command “fg % job number”. This should bring whatever job number you chose from the background to the foreground. If you want to resume it again in the background just use “fg %job number&”

Archiving/Unarchiving

Archiving is a useful tool to know in linux. It can take a collection of files and/or directories and put it all into one place, known as a archive. There are many archiving tools in the linux terminal and you choose one that fits your needs. I am going to show you an example of one archiver right now called Tar:

lab46:~$ ls
Desktop            archives           hi             public_html
Harchives.tar.bz2  bin                hi.c           regularexpressions
Maildir            botopen            hi.s           scriptrgex.sh
Puzzlewin          candy              in             soaringeagle.sh
Scanned1-1.png     closet             irc            soaringeagle1.sh
Scanned1.png       cmdcprog.c         killerwasp.sh  src
Scanned2-1.jpg     contact.info.save  lab1a.text     temp
Scanned2.jpg       courses            lyrics.mp3     temp.c
a.out              data               motd           the answer.txt
addscr.sh          destructo.sh       newdirectory   tmp
archive1.tar.gz    dl                 program        try3.png
archive2.zip       exper              program.c      wildcards
archivees          hey                pss
lab46:~$ tar cvzf Cexetension.tgz *.c
cmdcprog.c
hi.c
program.c
temp.c
lab46:~$ ls
Cexetension.tgz    archivees          hey            pss
Desktop            archives           hi             public_html
Harchives.tar.bz2  bin                hi.c           regularexpressions
Maildir            botopen            hi.s           scriptrgex.sh
Puzzlewin          candy              in             soaringeagle.sh
Scanned1-1.png     closet             irc            soaringeagle1.sh
Scanned1.png       cmdcprog.c         killerwasp.sh  src
Scanned2-1.jpg     contact.info.save  lab1a.text     temp
Scanned2.jpg       courses            lyrics.mp3     temp.c
a.out              data               motd           the answer.txt
addscr.sh          destructo.sh       newdirectory   tmp
archive1.tar.gz    dl                 program        try3.png
archive2.zip       exper              program.c      wildcards
lab46:~$

The archive should be highlighted red in your directory. What i did was archive any normal files with the c extension, hence why i called my archive “Cexetensions”. If you want to unarchive it, just find the extract commands you want in the man pages. I would use “tar xvzf Cexetensions.tgz” personally.

Compress/Decompress

If you want to have a smaller file because its too big to transfer or you just need more space, use the zip command. This command will compress files down and give it the file extension “.z”. When you compress you will not be able to read contents unless you decompress, and you would just use the decompress command.

lab46:~$ zip -r example3 closet
  adding: closet/ (stored 0%)
  adding: closet/skeleton (stored 0%)
  adding: closet/candy
zip warning: Permission denied
        zip warning: could not open for reading: closet/candy
  adding: closet/cake (deflated 2%)

zip warning: Not all files were readable
  files/entries read:  3 (42 bytes)  skipped:  1 (0 bytes)
lab46:~$ ls
Cexetension.tgz    archives           hi             regularexpressions
Desktop            bin                hi.c           scriptrgex.sh
Harchives.tar.bz2  botopen            hi.s           soaringeagle.sh
Maildir            candy              in             soaringeagle1.sh
Puzzlewin          closet             irc            src
Scanned1-1.png     cmdcprog.c         killerwasp.sh  temp
Scanned1.png       contact.info.save  lab1a.text     temp.c
Scanned2-1.jpg     courses            lyrics.mp3     the answer.txt
Scanned2.jpg       data               motd           tmp
a.out              destructo.sh       newdirectory   try3.png
addscr.sh          dl                 program        wildcards
archive1.tar.gz    example3.zip       program.c
archive2.zip       exper              pss
archivees          hey                public_html
lab46:~$

In there you should see a new zip file that i called example3. There are some errors saying permission denied, that is because i have some files with certain permissions on them so they can not be touched. But if you want to simply uncompress this file just use the command unzip and the contents should be extracted.

Shell Scripting

Shell scripting is a way to execute commands and processes by using one single executable file. You can write this in a text editor like vi, use very high level programming like pseudo coding and write it all out. then after that, save it and execute and it should run commands for you out on the commandline so you dont even have to type each command one by one. Here is an example:

 1 #!/bin/bash
  2 cd ~/tmp
  3 for file in `/bin/ls -1A `; do
  4     fname="`echo $file|cut -d'.' -f1`"
  5     mv -v $file $fname
  6 done
  7 exit 0

As you can see, it goes through the commands cd and mv, while doing some text manipulation.

Home Directory

The Home Directory is where you keep all of your files, your text files, audio files and any other directories you might have. All permissions are set for your use and yours only, unless you change it. the “~” represents that you are in your home directory and ls will list all your files in it. cd will also take you to your home directory no matter where you are.

lab46:~$ ls
Cexetension.tgz    archives           hi             regularexpressions
Desktop            bin                hi.c           scriptrgex.sh
Harchives.tar.bz2  botopen            hi.s           soaringeagle.sh
Maildir            candy              in             soaringeagle1.sh
Puzzlewin          closet             irc            src
Scanned1-1.png     cmdcprog.c         killerwasp.sh  temp
Scanned1.png       contact.info.save  lab1a.text     temp.c
Scanned2-1.jpg     courses            lyrics.mp3     the answer.txt
Scanned2.jpg       data               motd           tmp
a.out              destructo.sh       newdirectory   try3.png
addscr.sh          dl                 program        warning:.zip
archive1.tar.gz    example3.zip       program.c      wildcards
archive2.zip       exper              pss
archivees          hey                public_html
lab46:~$

cprog Objective

Objective

understand the difference between procedural and object-oriented languages

Method

To show the I know the difference, i will show 2 programs. One that is object oriented and one that is procedural.

Measurement

Follow your method and obtain a measurement. Document the results here.

#include <stdio.h>
 
int main(void)
{
    printf("hello, world\n");
    return 0;
}

A list of instructions telling a computer, step-by-step, what to do, usually having a linear order of execution from the first statement to the second and so forth with occasional loops and branches. This is an procedural program. This is a very simple program but it can been seen it reads from top to bottom when it is executed.

   // program start.cpp
     #include  <iostream>
     using namespace std;
      
      struct   item     // a struct data type
        {
              int  keep_data;
         };
         
   void main()
    {
         item   John_cat, Joe_cat, Big_cat;
         int   garfield;   // a normal variable
        
         John_cat.keep_data = 10;      // assigning values
         Joe_cat.keep_data = 11;
         Big_cat.keep_data = 12;
         garfield = 13;
      
        // displaying data
        cout<<"Data value for John_cat is "<<John_cat.keep_data<<"\n";
        cout<<"Data value for Joe_cat is  "<<Joe_cat.keep_data <<"\n";
        cout<<"Data value for Big_cat is  "<<Big_cat.keep_data<<"\n";
        cout<<"Data value for garfield is "<<garfield<<"\n";
        cout<<"Press Enter key to quit\n";
        // system("pause");
    }

Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. This is a very simple example of object orientation, but if you can tell, it does not go step by step, it has structures with different values and they call each other. This is c++ language, c++ is OO most of the time, While c is very procedural.

Analysis

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

unix Objective

Objective

Exposure to command-line tools and utilities. This is the ability to effectively use commands and utilities to navigate and use linux to its full potential.

Method

To prove i have reached this objective i will show various amounts of commands and tools that i can use in the terminal.

Measurement

lab46:~$ man
What manual page do you want?
lab46:~$ ls
Cexetension.tgz    archives           hi             regularexpressions
Desktop            bin                hi.c           scriptrgex.sh
Harchives.tar.bz2  botopen            hi.s           soaringeagle.sh
Maildir            candy              in             soaringeagle1.sh
Puzzlewin          closet             irc            src
Scanned1-1.png     cmdcprog.c         killerwasp.sh  temp
Scanned1.png       contact.info.save  lab1a.text     temp.c
Scanned2-1.jpg     courses            lyrics.mp3     the answer.txt
Scanned2.jpg       data               motd           tmp
a.out              destructo.sh       newdirectory   try3.png
addscr.sh          dl                 program        warning:.zip
archive1.tar.gz    example3.zip       program.c      wildcards
archive2.zip       exper              pss
archivees          hey                public_html
lab46:~$ cd archives
lab46:~/archives$ ls
abc.txt  filea  fileb  filec
lab46:~/archives$ cat filea
archives/abc.txt0000640001307400116100000000005207422045260013331 0ustar  dgirar                                                                                                 d3lab46This is an example file for use in CT173.
archives/fileb0000640001307400116100000000000007422045275013046 0ustar  dgirard3                                                                                                 lab46archives/filec0000640001307400116100000000000007422045275013047 0ustar  dgi                                                                                                 rard3lab46archivees/filea0000640001307400116100000000002407422045373013217 0usta                                                                                                 r  dgirard3lab46This contains text.
archivees/filez0000640001307400116100000000000007422045411013233 0ustar  dgirard                                                                                                 3lab46lab46:~/archives$ cd
lab46:~$ file closet
closet: directory
lab46:~$ ps | grep screen
dgirard3 15155  0.0  0.0  10084   852 pts/39   SN+  03:01   0:00 grep screen
lab46:~$ who
NAME       LINE         TIME             IDLE          PID COMMENT
synack   + pts/0        2011-10-18 13:38  old        14016 (184.72.226.125)
bblack1  + pts/1        2011-10-30 23:21 03:38       29290 (cpe-72-230-208-87.st                                                                                                 ny.res.rr.com)
jjohns43 + pts/2        2011-10-10 21:34 03:30        1072 (cpe-74-65-82-173:S.0                                                                                                 )
mgough   + pts/8        2011-10-11 19:15 03:48        4076 (rrcs-50-75-97-143:S.                                                                                                 0)
dgirard3 + pts/39       2011-10-31 02:57   .         14384 (cpe-67-241-224-129.s                                                                                                 tny.res.rr.com)
asowers  + pts/28       2011-10-30 11:57 15:03       30168 (cpe-67-241-233-254.s                                                                                                 tny.res.rr.com)
lab46:~$ ./hi
hello
lab46:~$ cd
lab46:~$ cd ..
lab46:/home$ ls
ab000126  aromero    bort      clawren2  ddragoo   dstorm3   gc007950    jbesecke  jjohns43  jsmit176  kcaton    llaughl3  mowens3    pdowd       rosenbll  squires   tl009536
abranne1  as012495   bowlett1  cmace1    dfoulk1   dtalvi    gcalkin3    jblaha    jjohnst8  jstrong4  kcook6    lleber    mp018526   plindsa1    rpage3    squirrel  tmizerak
abrunda1  ascolaro   brian     cmahler   dgirard3  dtaylo15  ggamarra    jblanch1  jkingsle  jsulli34  kcornel6  lmcconn4  mpaul6     pm004968    rpetzke1  srk3      tmong
acanfie1  asmedley   brobbin4  cmcavoy   dh002925  dtennent  gr015546    jbrant    jkremer1  jsulliv3  kdenson   lmerril3  mpresto4   pmcconn1    rraplee   srog      tp001498
acarpen5  asowers    bstoll    cmille37  dh018304  dtravis4  groush1     jbrizzee  jlantz4   jt011443  kgarrah1  mallis3   mshort3    qclark      rrichar8  ssmith85  triley2
acrocker  astrupp    btaber2   cmulkeri  dherman3  dwalrat1  gsnyder     jburlin1  jlazaar   jtongue2  kgaylord  mbeschle  mtaft4     radams4     rshaw8    sswimle1  ts004985
adexter   atoby      bwheat    cnicho13  dlalond1  dwells6   haas        jc006215  jluedema  jtreacy   kinney    mbonacke  mwagner3   rberry3     rthatch2  strego    vcordes1
adilaur1  atownsle   bwilso23  comeaubk  dm005264  dwrigh18  hansolo     jcardina  jm010967  jtripp    kkrauss1  mbrigham  mwarne11   rbuchan7    ryoung12  svrabel   wag2
aettenb3  atreat2    bwilson3  cpainter  dmagee3   eberdani  hclark9     jcosgro4  jmanley3  jv001406  klynch3   mbw6      mwitter3   rcaccia1    sblake3   swarren4  wedge
afassett  awalke18   cas21     critten1  dmay5     efarley   hepingerjj  jdavis34  jmille59  jvanott1  kpryslop  mclark35  nandre     redsting3d  sc000826  sweller5  wezlbot
agardin4  bblack1    caustin8  csleve    dmurph14  egarner   hhabelt     jdawson2  jmitch22  jwalrat2  kreed11   mcooper6  nbaird     reedkl      sclayton  swilli31  wfischba
ajernig2  bbrown17   ccaccia   cspenc12  dpadget8  egleason  hps1        jdrew     jmunson   jwhitak3  kscorza   mdecker3  nblancha   rfinney2    sedward9  syang     wknowle1
ajoensen  bdevaul    ccarpe10  csteve16  dparson3  emorris4  hramsey     jeisele   jmyers7   jwilli30  ksisti2   mdittler  ngraham2   rglover     sjankows  synack    wroos
alius     bewanyk    cchandan  cwagner1  dpotter8  en007636  hshaikh     jellis15  jo009612  jwilso39  kwalker2  mearley1  nrounds    rhender3    sjelliso  tcolli12  ystebbin
amorich1  bfarr2     ccranda2  cwilder1  dprutsm2  erava     hwarren1    jfrail    jphill17  jwood36   lburzyns  mfailing  nsano      rj005436    smacombe  tdoud     zlittle
anarde    bh011695   cderick   cwoolhis  drobie2   erebus    ian         jfurter2  jr018429  jzimmer5  lcrowley  mgough    nsr1       rjohns41    smatusic  tfitch1   zward
anorthr3  bherrin2   cdewert   darduini  ds000461  estead    imaye       jh001093  jrampul1  kamakazi  ld010818  mguthri2  nvergaso   rkapela     smclaug3  tgalpin2
anowaczy  bhuffner   cforman   dates     ds003420  eveilleu  jandrew9    jhall40   jsabin1   kbell1    leckley   mhenry9   nwebb      rlott       smd15     thatcher
ap016986  bkenne11   cgoodwin  db010905  dschoeff  ewester1  javery9     jhammo13  jschira1  kboe      lgottsha  mkellogg  oppenheim  rm002127    smilfor3  tjohns22
appelthp  bnichol7   ckelce    dchilso3  dshadeck  ezajicek  jbaez       jj001572  jshare1   kc017344  lh000592  mkelsey1  pclose     rmoses      spetka    tkane1
aradka    bobpauljr  ckuehner  dcicora1  dshreve   fclark1   jbarne13    jjansen4  jshort6   kcard2    lhubbar3  mmatt     pcremidi   rnewman     spline    tkiser
lab46:/home$ cd ..
lab46:/$ ls
bin  boot  dev  etc  home  initrd.img  lib  lib32  lib64  lost+found  media  mnt  opt  proc  root  sbin  selinux  srv  sys  tmp  usr  var  vmlinuz
lab46:/$ cd
lab46:~$ who
NAME       LINE         TIME             IDLE          PID COMMENT
synack   + pts/0        2011-10-18 13:38  old        14016 (184.72.226.125)
bblack1  + pts/1        2011-10-30 23:21 03:40       29290 (cpe-72-230-208-87.stny.res.rr.com)
jjohns43 + pts/2        2011-10-10 21:34 03:32        1072 (cpe-74-65-82-173:S.0)
mgough   + pts/8        2011-10-11 19:15 03:50        4076 (rrcs-50-75-97-143:S.0)
dgirard3 + pts/39       2011-10-31 02:57   .         14384 (cpe-67-241-224-129.stny.res.rr.com)
asowers  + pts/28       2011-10-30 11:57 15:05       30168 (cpe-67-241-233-254.stny.res.rr.com)
lab46:~$

next i will open up the vi editor.

lab46:~$ vi forobjective
lab46:~$

 1  this is for the objective to prove i can use and open up vi. I cant show any of the shorcuts i have used on here however i can at least show my ability to be on here

there are other text editors like nano. If i wanted i could easily read this file in the command line with a cat command. VI can also be used to shell script which i have many scripts wrriten (files with sh extension) i also have c programs used in the vi editor (.c extensions) I also have a file that edits vi once it opens, i will show you.

 1 syn on
  2 set tabstop=4
  3 set shiftwidth=4
  4 set nu
~
~

These are in the vi text editor and this will change my vi settings everytime i go to use it.

Analysis

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

Experiments

Experiment 1

Question

Can there be a space in a file/directory name?

Resources

Any information will be knowledge from class.

Hypothesis

I believe you can because its not that hard to put it into quotes of some sort to show that its all one thing, and not separated.

Experiment

I will show you a file with a space in it or create one of my own to prove its possible.

Data


lab46:~$ ls
Cexetension.tgz    archives           hey            public_html
Desktop            bin                hi             regularexpressions
Harchives.tar.bz2  botopen            hi.c           scriptrgex.sh
Maildir            candy              hi.s           soaringeagle.sh
Puzzlewin          closet             in             soaringeagle1.sh
Scanned1-1.png     cmdcprog.c         irc            src
Scanned1.png       contact.info.save  killerwasp.sh  temp
Scanned2-1.jpg     courses            lab1a.text     temp.c
Scanned2.jpg       data               lyrics.mp3     the answer.txt
a.out              destructo.sh       motd           tmp
addscr.sh          dl                 newdirectory   try3.png
archive1.tar.gz    example3.zip       program        wildcards
archive2.zip       exper              program.c
archivees          forobjective       pss
lab46:~$

before this experiment i forgot i found a file that was named “the answer.txt” for project i did and so it is possible to create and read one but i am going to attempt to make my own to see if i can do it.

lab46:~$ mkdir "for experiment"
lab46:~$ ls
Cexetension.tgz    archives           forobjective   pss
Desktop            bin                hey            public_html
Harchives.tar.bz2  botopen            hi             regularexpressions
Maildir            candy              hi.c           scriptrgex.sh
Puzzlewin          closet             hi.s           soaringeagle.sh
Scanned1-1.png     cmdcprog.c         in             soaringeagle1.sh
Scanned1.png       contact.info.save  irc            src
Scanned2-1.jpg     courses            killerwasp.sh  temp
Scanned2.jpg       data               lab1a.text     temp.c
a.out              destructo.sh       lyrics.mp3     the answer.txt
addscr.sh          dl                 motd           tmp
archive1.tar.gz    example3.zip       newdirectory   try3.png
archive2.zip       exper              program        wildcards
archivees          for experiment     program.c
lab46:~$

ok its possible :)

Analysis

Based on the data collected:

Conclusions

I am certain that your files and directories are not limited to a single word line, it can have spaces you just have to know how to manipulate your command line the right way to work for you.

Experiment 2

Question

Can you compile assembly code the same way you compile c code?

Resources

Just going to take what i know from class and implement it here

Hypothesis

I think you can compile it the same way, essentially its the same code just with different syntax. I am just not sure if it requires anything special to be done because its such a low level, so maybe it will act differently.

Experiment

I will show you within the lab46 terminal by running commands and executing a program.

Data

lab46:~$ ls
Cexetension.tgz    archives           forobjective   pss
Desktop            bin                hey            public_html
Harchives.tar.bz2  botopen            hi             regularexpressions
Maildir            candy              hi.c           scriptrgex.sh
Puzzlewin          closet             hi.s           soaringeagle.sh
Scanned1-1.png     cmdcprog.c         in             soaringeagle1.sh
Scanned1.png       contact.info.save  irc            src
Scanned2-1.jpg     courses            killerwasp.sh  temp
Scanned2.jpg       data               lab1a.text     temp.c
a.out              destructo.sh       lyrics.mp3     the answer.txt
addscr.sh          dl                 motd           tmp
archive1.tar.gz    example3.zip       newdirectory   try3.png
archive2.zip       exper              program        wildcards
archivees          for experiment     program.c
lab46:~$ gcc -o experiment hi.s
lab46:~$ ls
Cexetension.tgz    archives           for experiment  program.c
Desktop            bin                forobjective    pss
Harchives.tar.bz2  botopen            hey             public_html
Maildir            candy              hi              regularexpressions
Puzzlewin          closet             hi.c            scriptrgex.sh
Scanned1-1.png     cmdcprog.c         hi.s            soaringeagle.sh
Scanned1.png       contact.info.save  in              soaringeagle1.sh
Scanned2-1.jpg     courses            irc             src
Scanned2.jpg       data               killerwasp.sh   temp
a.out              destructo.sh       lab1a.text      temp.c
addscr.sh          dl                 lyrics.mp3      the answer.txt
archive1.tar.gz    example3.zip       motd            tmp
archive2.zip       exper              newdirectory    try3.png
archivees          experiment         program         wildcards
lab46:~$ ./experiment
hello
lab46:~$

I took the “hi.s” which is machine language and ran the compile command to compile it into “experiment” and it still executes just fine

Analysis

Based on the data collected:

Conclusions

As long as you have the right syntax of whatever code you are using, you can compile it withn the lab46 terminal using gcc -o. It will compile and execute normally

Experiment 3

Question

What happens when you mix up the .c file and the filename when compiling in linux?

Resources

My information comes from class :) so Matt Haas

Hypothesis

I believe it will not do anything to it, it shouldnt matter, right? as long as it has both files it should just know which is which.

Experiment

i will write a sample program and compile it the wrong way

Data

  1 #include <stdio.h>
  2 int main()
  3 {
  4     printf("hello\n");
  5     return(10);
  6 
  7 }

this is an easy simple code that i wrote, just for the use of this experiment. Now we will try to compile it the wrong way:

lab46:~/unixprog$ gcc -o hi.c ghjk
gcc: ghjk: No such file or directory
gcc: no input files
lab46:~/unixprog$ gcc -o poop hi.c
lab46:~/unixprog$ 

It yells at me when i do it the wrong way.

Analysis

No my hypothesis was wrong. I feel it was applicable just it was incorrect. There was nothing that i knew that wasnt going on and i knew what to expect if something happened. There were no shortcomings in either data or experiment.

Conclusions

This was an easy project and i just needed to know what would happened if i did this, and no i know.