User Tools

Site Tools


opus:spring2012:jpettie:part1

Part 1

Entries

Entry 1: February 9th, 2012

On the 9th of February we learned how to use arrays to take a user inputted word and break it into letter parts, store it in an array, and finally print it to the screen along with the letter ASCII values. This was of significance because we learned how to use an manipulate elements of an array with pointers and how to manipulate user input. We used the array word with pos for positioning and indexing parts of the word array for each letter, and to use those indexes of the word array to find things out about the letters. I did not find anything confusing when writing this program along with the instructor, but I have worked with arrays before.

Here is the source code of the program that was written in class on the 9th of February:

#include <stdio.h>
#include <stdlib.h>
 
int main(){
        char *word, len = 0, x, pos = 0;
        word = (char *)malloc(sizeof(char)*24);
        fprintf(stdout, "Please enter a word: ");
        fscanf(stdin, "%s", word);
        x = *(word + pos);
        while ((x != '\0')&&(x != '\n')){
                printf("In this while, x is %hhd\n", x);
                len++;
                pos++;
                x = *(word + pos);
        }
        for (pos = 0; pos < len; pos++){
                fprintf(stdout, "%c", *(word + pos) - 32);
        }
        fprintf(stdout, "\n");
        return(0);
}

Entry 2: February 14th, 2012

On the 14th of February we learned how to use the main() function's inherited parameters to accept input in a different way than we are used to. This was of significance because it was a new way of accepting input in a more efficient way that is already included in the c language when we use the main() function. This is a very useful method of accepting arguments when the program is first run and a very efficient way of defining those arguments and having a pointer to point to them. I find that the main() function's parameters are confusing at first to work with and I have no documentation yet of the main() function, but I would assume it is part of the <stdio.h> file. There have yet to be too many challenges that I have not been able to overcome, due to the way the material is presented and the time given to play with the things we learn.

Here is the source code of the program that was written in class on the 14th of February:

#include <stdio.h>
#include <stdlib.h>
 
int main(int argc, char **argv){
        unsigned char i;
        if (argc<2){
                printf("%8s must be run with 1 or more arguments, you only provide %hhu\n", *(argv+0), (argc-1));
                exit(1);
        }
        printf("You ran this program with a %hhu arguments, they are:\n", argc);
        for (i = 0; i < argc; i++){
                printf("argv[%hhu]: %s\n", i, *(argv+i));
        }
        return(0);
}

Entry 3: February 16th, 2012

On the 16th of February we were made to write a program that associated everything we had done in class previously and outside of class to show that we could apply what we had learned so far. This was of significance because it was a way to not only test yourself but to show to the teacher that you could learn efficient through his methods, and through your own personal time devoted to the subject. If you were able to complete the task in the class period time available, it was a statement that said you understood everything taught so far in the class and were able to duplicate it and manipulate it all into one program. Some of the concepts that might not make perfect sense to me are mostly just pointers, but I feel as I find more uses for pointers, I will understand them more. I find that I am not facing too much of a challenge because I have experience with the subject matter through many different opportunities I have been given.

Here is the source code of the program that was written in class on the 16th of February:

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
 
int main(int argc, char **argv){
        int input;
        bool check = false;
        unsigned char i;
        while (check == false){
                printf("Enter a value (0-4):");
                scanf("%d", &input);
                if (input > 4 || input < 0){
                        printf("You have entered an incorrect value.\n");
                        check = false;
                }else{
                        for (i = 0; i < argc; i++){
                                printf("argv[%hhu][%hhu]: %c\n", i, input, *(*(argv+i)+input));
                        }
                        check = true;
                }
        }
        return(0);
}

Entry 4: February 16th, 2012

On the 16th of February I created virtual machines on the virtual machine server my group had created early in the HPC class. This was of significance because it will allow me to complete the network services project which comes next in my order of things and I plan on creating a proxy of some sort. Some of the problems that I ran into would include file modifications for xm##.cfg mirror links and problems with the xen conf file. I find that I am facing challenges every day in HPC and in turn learning a lot about cool projects that can be completed with the tools we learn each day through direct experience and really just diving right into things to learn about them, which is actually my favorite way of learning.

Here is the commands I had to run to complete the project:

root@vmserver02:~# xm create -c /xen/conf/vm31.cfg
root@vmserver02:~# xm create /xen/conf/vm31.cfg
lab46:~$ ssh root@vm31.student.lab

Keywords

cprog Keywords

cprog Keyword: Pointers

Definition

Pointers to me are used as a way of referencing something without calling it directly, and they are useful as I have seen because you can change the location a pointer points at depending on the situation and outcome you desire. You could even use an array of pointers to complete a task. I look at pointers as a reference or indirect direct way to change and manipulate something without using the thing that is being changed or manipulated.

Demonstration

To use pointers, there are a couple of things to consider:

  • Address of: *value = &x (Pointing value (a pointer) to the address of the variable x)
  • Dereferencing: *value (* denotes the dereference of a variable, making it a pointer) (This makes it container less)
  • Assignment: You will notice below with a demonstration how to assign a pointer. (char *value; value = (char *)malloc(sizeof(char)*4);)

To demonstrate pointers, I will show a code block using pointers and its output.

#include <stdio.h>                                                                                      
#include <stdlib.h>                                                                                    
 
int main(){                                                                                             
        char *value, i;                                                                                 
        value = (char *)malloc(sizeof(char)*4);                                                         
        *(value+0)=0;                                                                                   
        *(value+1)=1;                                                                                  
        fprintf(stdout, "Please enter a value (-128 - +127): ");                                       
        fscanf(stdin, "%hhd", &i);                                                                      
        *(value+2)=i;                                                                                   
        *(value+3)=(2*i)+3;
        for (i = 0; i <= 3; i++){                                                                       
                printf("%hhd\n", *(value+i));
        }                                                                                               
        return(0);                                                                                     
} 
lab46:~$ gcc -o prog7 prog7.c
lab46:~$ ./prog7
Please enter a value (-128 - +127): 8                                                                   
0                                                                                                       
1
8                                                                                                       
19
lab46:~$ 

cprog Keyword: Selection Structures (if, case/switch)

Definition

Selection Structures are conditional statements that determine a path to take depending on the state of the condition. (True/False)

Demonstration

To demonstrate a Selection Structure, I will be using the If Selection Structure.

if (input > 4 || input < 0){
   printf("You have entered an incorrect value.\n");
   check = false;
}else{
   for (i = 0; i < argc; i++){
   printf("argv[%hhu][%hhu]: %c\n", i, input, *(*(argv+i)+input));
}

cprog Keyword: Repetition/Iteration Structures (for, while, do while)

Definition

Repetition/Iteration Structures are a way of repeating certain contents of code until a condition is satisfied. They are usually defined mostly by whether a statement is True or False, and in the case of a while, as long as the statement is True, the while will continue to iterate.

Demonstration

As a demonstration, I will show a code example of a while loop and a for loop.

while (check == false){
   printf("Enter a value (0-4):");
   scanf("%d", &input);
   if (input > 4 || input < 0){
      printf("You have entered an incorrect value.\n");
      check = false;
   }else{
      for (i = 0; i < argc; i++){
         printf("argv[%hhu][%hhu]: %c\n", i, input, *(*(argv+i)+input));
      }
      check = true;
   }
}

cprog Keyword: Header Files (Local and System), C Standard Library (Libc), Libraries

Definition

Header Files are files that are applied to c code to incorporate libraries for use of their functions and data structures.

Demonstration

This demonstration will show a couple header files being included in a c code environment.

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

cprog Keyword: logic and operators (and, or, not, xor)

Definition

Logic and operators include devices for comparing and assigning variables. For example: int x = 0 (The '=' assigns the integer value of 0 to the integer variable x).

Demonstration

Demonstration for this keyword will include using AND (&&), OR (||), GREATER THAN (>), LESS THAN (<), and the Assignment Operator ( = ).

if (input > 4 || input < 0){
   check = false;
}
if (input > 4 && input < 0){
   check = true;
}

cprog Keyword: Arrays (standard notation, pointer arithmetic, single-dimensional, multi-dimensional)

Definition

Arrays can be thought of as containers with indexes to each element in their ordered container. The ability to store data separately within a container and be able to access it easily with an index is the reason why Arrays are so useful. Arrays to me are dynamic storage containers with easily accessed schemes of data.

Demonstration

In this demonstration, I will be showing in c code some different Array types.

int argc; //Array of integers
char **argv; //Array of character pointers
int x[2]; //Array of integers with a size of 2
int t[2][2]; //Multidimensional Array with a Row size of 2 and Column size of 2

cprog Keyword: Standard I/O (STDIO, STDOUT, STDERR)

Definition

Standard I/O is a library of input, output, and error message types to be prompted to the terminal screen. Standard I/O must be included in a programming file such as .c for its input, output, and error message functions to work.

Demonstration

What follows is a demonstration of including Standard I/O to a .c file and using some of its functions to perform prompting tasks.

#include <stdio.h>
 
fprintf(stdout, "Please enter a value (-128 - +127): ");
fscanf(stdin, "%hhd", &i);

cprog Keyword: Functions

Definition

Functions as used by me are a set of instructions that can be defined by a name and referenced by the main part of a program to complete some sort of sub task to a greater full task.

Demonstration

Here is an example of functions in the language c:

  1 #include <stdio.h>
  2
  3 int sum(int, int, int, int);
  4 float average(int, int, int, int);
  5
  6 int main(){
  7         int a, b, c, d, high, low;
  8         a = b = c = d = 0;
  9         printf("Enter first value: ");
 10         fscanf(stdin, "%d", &a);
 11         printf("Enter second value: ");
 12         fscanf(stdin, "%d", &b);
 13         if (a > b){
 14                 high = a;
 15                 low = b;
 16         }else{
 17                 low = a;
 18                 high = b;
 19         }
 20         printf("Enter third value: ");
 21         fscanf(stdin, "%d", &c);
 22         if (c > high){
 23                 high = c;
 24         }else{
 25                 if (c < low){
 26                         low = c;
 27                 }
 28         }
 29         printf("Enter fourth value: ");
 30         fscanf(stdin, "%d", &d);
 31         if (d > high){
 32                 high = d;
 33         }else{
 34                 if (d < low){
 35                         low = d;
 36                 }
 37         }
 38         fprintf(stdout, "The sum of %d, %d, %d, and %d is: %d\n", a, b, c, d, sum(a, b, c, d));
 39         fprintf(stdout, "The average of %d, %d, %d, and %d is: %f\n", a, b, c, d, average(a, b, c, d));
 40         fprintf(stdout, "The highest input is: %d\n", high);
 41         fprintf(stdout, "The lowest input is: %d\n", low);
 42         return(0);
 43 }
 44
 45 int sum(int n1, int n2, int n3, int n4){
 46         return(n1 + n2 + n3 + n4);
 47 }
 48
 49 float average(int n1, int n2, int n3, int n4){
 50         return((float)(n1 + n2 + n3 + n4)/4);
 51 }

cprog Objective

cprog Objective

Write and compile code that utilizes programming constructs.

Definition

This objective entails the use of nano or vi along with the use of gcc to write and compile code within a certain standard of syntax and purpose.

Method

The method to which I will use to measure my success in this objective is to show the steps and examples of how I have already completed this objective.

Measurement

Steps to completing this objective include:

1. The use of nano or vi to edit text and create a .c file type.

lab46:~$ nano test.c 
lab46:~$ vim test.c 
#include <stdio.h>
 
int main()
{
    printf("Testing a printf.");
    return(0);
}

2. The use of gcc to compile code and check the syntax of the code.

lab46:~$ gcc -o test test.c
lab46:~$ 

3. Testing the code by running the file that I have compiled the .c file to.

lab46:~$ ./test
Testing a printf.
lab46:~$ 
Analysis

Reflections:

  • I believe I have done well and have shown success in this objective.
  • I believe the room for improvement lays in the matter of programming constructs.
  • I believe the measurement could be more effective with code examples as I have used above.
  • I do have the belief that this would be an effective and simple employment.
  • I do not believe the course objective should be altered in any way.

hpc0 Keywords

hpc0 Keyword "Screen"

Definition

Screen to me, in unix, is an orgasmic experience of endless possibilities. It is the very meaning of multitasking efficiently and its uses are endlessly approaching greatness, like the graph of 1/x, it never reaches fully to 0, but it will always be getting closer and closer to perfect value and significance. Putting all my admiration aside, screen is used to create a session of many windows within a terminal window. Well, you ask, why is it called “Screen” if it creates a plural cornucopia of windows of great potential. Well, don't be a dummy, keep it simple stupid, think of it as a frame or structural base that you build upon and a very sturdy one if you ask me. So, if you find yourself wanting to multitask your butt off, or you just really want to show off to all your friends, you should get to know your new best friend, “Screen”.

Demonstration

Demonstration of the chosen keyword.

So, are you finally ready to be the future, be the unstoppable, well, you'll be more efficient at the least. Then follow me on this great journey and you shall find the greatness in all things that are “Screen”. Fine, I get it, you are tired of me talking so much. Without further ado I shall now show you the awesome-sauce that is “Screen”…

*Awesome Eye of the Tiger Music comes on in the background*

lab46:~$ screen

Make sure to say “y” or “yes” when installing/setting up screen.

lab46:~$ screen -ls
There is a screen on:
        13985.pts-50.lab46      (02/14/2012 12:17:40 PM)        (Attached)
1 Socket in /var/run/screen/S-jpettie.

hpc0 Keyword: Screen Cont.

Definition

Dude, you totally made the right choice in choosing to continue your knowledge of the Screen universe with me. So, lets get to it, right!?

..Right.

There are things you just must know about screen to really make it shine and once you realize what you are doing, you will be amazed.

Disclaimer: If you are one of those guys who are like, I ain't ever amazed bro, sit back and watch the magic yo, and I ain't yo bro dude.

In this section of the continuum of Screen, we will discuss some useful keystrokes to manipulate Screen to your needs, or is it Screen that is manipulating you? That is the question indeed. What better way to do such a thing than with Hotkeys, lets kick it old school yo.

Hotkeys

Attach to a screen session:

lab46:~$ screen -r

Control Command Hot-key Combinations for Reference (Simple):

  • Control + c: Create new window.
  • Control + a + a: Swap between windows.
  • Control + “: Show all windows running.
  • Control + a + A: Name current window.
  • Control + a + k: Destroy current window.
  • Control + a + n: Change to next window.
  • Control + a + p: Go back a window.
  • Control + a + \: Destroy all windows.
  • Control + a + D: Detach from running Screen.

Disclaimer: If you don't believe me, jerk…, anyway, use:

  • Control + a + ?: Shows list of all commands.

hpc0 Keyword: Screen Split

Definition

So now you understand how to create windows, name windows, swap between windows, even how to kill windows, and you ask, is that it? Maybe you'd even say I guess that is alright, its kinda cool. Well, there is more to this story than you might realize at first sir. Get ready to have your mind blown and your efficiency level skyrocket to over 9000!!!!!!

The story began back when someone decided that should open two terminals because they want to work on two different windows at the same time, and maybe they used win 7 to snap it to either side of their screen, well, I am here to save you from opening too many screens and endless terminals to multitask. It can be done in Screen, and it is time you learn how to do it.

Demonstration

The commands you'll want to know to split your screen into vertical and horizontal windows as many times as you'd like are as follows:

  • Control + a + S: Split screen into n windows horizontally (where n is how many times you do such a thing, feel free to do this a lot, its fun, trust me.).
  • Control + a + | (Don't get this confused with the letter 'l' or the letter 'i', it is a pipe, or rather a shift '\'): Split screen into n windows vertically
  • Control + a + TAB: Swap focus between the split windows in screen. (Multitask be yours, like magicks yo)
  • Control + a + X: Destroy a window.

And so you can see the magic that will happen, here is an example of what you can expect to create:

               words?                                                                                   jpettie@lab46:~/src$ cd unix
21:35 < Jacob> thats exactly what I was going for, how did you know?                                    jpettie@lab46:~/src/unix$ ls
21:36 < wedge> no, the ultimate aim is for it to be readable and informative, and especially to the     cs1.txt  lab0.txt  lab1.txt
               original author months down the road                                                     jpettie@lab46:~/src/unix$ ls
21:36 < wedge> but, seeing as it is publicly accessible, just know that the intarwebz can also read it  cs1.txt  lab0.txt  lab1.txt
21:39 < Jacob> well, I just wanted to use awesome-sauce                                                 jpettie@lab46:~/src/unix$ ls -all
21:39 < wedge> feel free                                                                                total 12
21:39 < wedge> I think it makes it more enjoyable                                                       drwxr-xr-x 3 jpettie lab46   61 Jan 28 18:57 .
21:40 < Jacob> as long as you enjoy it, I should be doing well                                          drwx------ 6 jpettie lab46   68 Jan 28 18:40 ..
21:41 < wedge> to enjoy and be informed                                                                 drwxr-xr-x 6 jpettie lab46   92 Jan 31 16:52 .svn
21:41 < Jacob> gonna hit the world with matrix level stuff, when I hit splits                           -rw-r--r-- 1 jpettie lab46  705 Jan 28 18:57 cs1.txt
21:41 < wedge> knock knock neo                                                                          -rw-r--r-- 1 jpettie lab46 2489 Jan 25 14:38 lab0.txt
21:43 < wedge> anywho... I'm going to wander... any last requests?                                      -rw-r--r-- 1 jpettie lab46 3327 Jan 28 18:56 lab1.txt
21:43 < Jacob> knock knock , endless screen possibilities                                               jpettie@lab46:~/src/unix$
21:43 < Jacob> um, don't check it until tomorrow at 1?                                                  jpettie@lab46:~/src/unix$
21:43 < Jacob> hahah
21:44 < wedge> 0100 hours?
21:44 < wedge> :)
21:44 < Jacob> just joking
21:44 < Jacob> I'll have a lot done by midnight
21:44 < Jacob> most likely all of it
21:44 < wedge> I'll likely not be looking at it until tomorrow afternoon at the earliest
21:45 < wedge> good night all
21:46 < Jacob> I be good student from now on
21:46 < Jacob> ;p
21:46 < Jacob> good night
21:57 < rmatsch> hey
21:58 < rmatsch> cat utility not working
22:26 < Jacob> how are you using it?
 [22:27] [Jacob(+i)] [4:irc/#unix(+Pnt)]
[#unix]
  0 irc                                                                                                   4 bash
  GNU nano 2.2.4                      File: icprog.c                                                    Sending on   Socket/fallback
                                                                                                        DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
#include <stdio.h>                                                                                      DHCPOFFER from 10.80.3.62
#include <stdlib.h>                                                                                     DHCPREQUEST on eth0 to 255.255.255.255 port 67
#include <stdbool.h>                                                                                    DHCPACK from 10.80.3.62
                                                                                                        bound to 10.80.3.31 -- renewal in 19118 seconds.
int main(int argc, char **argv){                                                                        done.
        int input;                                                                                      INIT: Entering runlevel: 2
        bool check = false;                                                                             Starting enhanced syslogd: rsyslogd.
        unsigned char i;                                                                                Starting OpenBSD Secure Shell server: sshd[   11.401708] NET: Registered protocol family 10
        while (check == false){                                                                         [   11.402227] lo: Disabled Privacy Extensions
                printf("Enter a value (0-4):");                                                         .
                scanf("%d", &input);                                                                    Starting periodic command scheduler: crond.
                if (input > 4 || input < 0){
                        printf("You have entered an incorrect value.\n");                               Debian GNU/Linux 5.0 vm31 hvc0
                        check = false;
                }else{                                                                                  vm31 login: vmserver02:~# ssh root@vm31.student.lab
                        for (i = 0; i < argc; i++){                                                     The authenticity of host 'vm31.student.lab (10.80.3.31)' can't be established.
                                printf("argv[%hhu][%hhu]: %c\n", i, input, *(*(argv+i)+input));         RSA key fingerprint is 39:41:a6:f0:21:67:ac:fc:3b:b6:55:8f:1d:2f:be:c6.
                        }                                                                               Are you sure you want to continue connecting (yes/no)? y
                        check = true;                                                                   Please type 'yes' or 'no': yes
                }                                                                                       Warning: Permanently added 'vm31.student.lab,10.80.3.31' (RSA) to the list of known hosts.
        }                                                                                               root@vm31.student.lab's password:
        return(0);                                                                                      Linux vm31 2.6.26-2-xen-686 #1 SMP Wed Sep 21 09:56:47 UTC 2011 i686
}
                                                                                                        The programs included with the Debian GNU/Linux system are free software;
                                                                                                        the exact distribution terms for each program are described in the
                                                                                                        individual files in /usr/share/doc/*/copyright.

                                                                                                        Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
^G Get Help      ^O WriteOut      ^R Read File     ^Y Prev Page     ^K Cut Text      ^C Cur Pos         permitted by applicable law.
^X Exit          ^J Justify       ^W Where Is      ^V Next Page     ^U UnCut Text    ^T To Spell        vm31:~#
  2 bash                                                                                                  6 bash

hpc0 Keyword: Virtualization

Definition

Virtualization is a way to create something that does not rely directly on the constraints of hardware.

Demonstration

A demonstration of this would be creating virtual machines on a virtual machine server which I have already implemented, but the way to create the virtual machines is as follows:

root@vmserver##:~# xm create -c /xen/conf/vm##.cfg
root@vmserver##:~# xm create /xen/conf/vm##.cfg

hpc0 Keyword: Configuration

Definition

Configuration has come to me in the meaning of changing the way something runs or starts up, depending on a file that is referenced by the service that uses it.

Demonstration

A demonstration of this would be for pvpgn, when I had to edit the .conf files of different services that make a whole of a server for the service of a pvpgn server to work correctly.

hpc0 Keyword: Backups

Definition

In our field, Backups are a very useful technique to create a restore point for a program or database and many other sorts of project files or directories before a big change or developmental process.

Demonstration

A demonstration of this is found at my work on a daily basis where we automate the backup of our mysql database so that if anything were to happen to it, we would be able to implement a restore to precious data.

hpc0 Keyword: Installation

Definition

Installation in my words would be the creation of a working copy of a program onto your computer from a downloaded source found online.

Demonstration

An example of this would be using Aptitude to install mysql.

vm31:~$ aptitude install mysql

hpc0 Keyword: Documentation

Definition

Documentation to me is a read me file or even a forget me file, pun intended. It is the bread and butter of working on someone else's code if they have comments inside their code explaining something about each part or how to run the program correctly.

Demonstration

Here is an example of documenting with comments in c code.

//This is an example comment line
/* This is an example of a multiple line comment
    Heres some more info
    and finally
*/

hpc0 Objective

hpc0 Objective

Demonstrate problem solving capabilities.

Definition

I believe what this objective can be defined as is a process that has been honed in on by the practice of completing projects of different levels of difficulty and expected outcomes.

Method

To show I have accomplished this objective, my method will include an example of a project where I have applied the practice of problem solving.

Measurement

Here is an example of a project I have completed by solving problems recently. The problems I encountered included bad mirror links in the cfg file of the xm virtual machine I was trying to create along with changes to the xm conf files before executing the creation of the virtual machine.

root@vmserver02:~# xm create -c /xen/conf/vm31.cfg
root@vmserver02:~# xm create /xen/conf/vm31.cfg
lab46:~$ ssh root@vm31.student.lab
Analysis

I believe I did well in performing this task and showing that I could solve the problems that I encountered along the way in completing the project. I definitely think that there is room for improvement in all things we do, but especially in problem solving. I have a philosophy that you have to experience a problem, or make a mistake to truly learn how to correct it and not repeat it in the future. I believe if I used a different project as an example with more detail going into how I approached and fixed the problems I came across, the measurement would be a more effective tool to show my skills. I believe it would be an efficient change to employ and I intend to do so in future opus Objective documentations. The course objective pretty much covers all it means to cover and should not be altered in any way, it is what it says, and problem solving is something people have to do every day in their lives no matter the field or task at hand.

unix Keywords

unix Keyword: The VI Editor

Definition

The VI Editor, one of the greats, nano on steroids. VI Editor is a text editor with much more to bring to the table, between its tools and its unique style of dealing with the editing of text. It is in simple a text editor with extras.

Demonstration

To demonstrate the VI Editor, I will show a fully functional VI Interface with the extra of line numbers and syntax highlighting:

lab46:~$ install vim
lab46:~$ vi test.c
  1 #include <stdio.h>
  2 #include <stdlib.h>
  3 #include <stdbool.h>
  4
  5 int main(int argc, char **argv){
  6         int input;
  7         bool check = false;
  8         unsigned char i;
  9         while (check == false){
 10                 printf("Enter a value (0-4):");
 11                 scanf("%d", &input);
 12                 if (input > 4 || input < 0){
 13                         printf("You have entered an incorrect value.\n");
 14                         check = false;
 15                 }else{
 16                         for (i = 0; i < argc; i++){
 17                                 printf("argv[%hhu][%hhu]: %c\n", i, input, *(*(argv+i)+input));
 18                         }
 19                         check = true;
 20                 }
 21         }
 22         return(0);
 23 }
 24

unix Keyword: Local host

Definition

Local host is the computer you are working on, it is the web address of the computer you are working on, it is a loopback in networking. Although local host can take many forms, it is simply your computer's identifier.

Demonstration

If you were to type: http://localhost into your web browser, you would be returned with the local web service of your computer.

unix Keyword: Remote host

Definition

Remote hosts are computers that are not locally accessed, rather are at a distance from where you are. They are still accessible and you can retrieve data from them, but they are a distance away.

Demonstration

Remote hosts are usually thought of as network servers or just servers in general, where you would ssh into. An example of this to me would be:

lab46:~$ ssh root@vm31.student.lab

unix Keyword: Home directory

Definition

The way I believe a home directory works, is that it can be a supply source for many users, who can separately have their own subsystems of directories but all refer back to a starting point. Even though it can be used by many, each is very different in its own right, different files and directories based on the user.

Demonstration

This demonstration will show a Home directory with many users.

lab46:~$ cd /home
lab46:/home$ ls
ab000126  bdevaul    cmcavoy   drobie2   haas        jhall40   jvanott1  lmcconn4  nrounds     rrichar8  tdoud
abranne1  bewanyk    cmille37  ds000461  hansolo     jhammo13  jwalrat2  lmerril3  nsano       rsantia4  tedmist1
abrunda1  bfarr2     cmulkeri  ds003420  hclark9     jj001572  jwhitak3  mallis3   nsr1        rshaw8    tfitch1
acanfie1  bh011695   cnicho13  dschoeff  hepingerjj  jjansen4  jwilli30  mbeschle  nvergaso    rthatch2  tgalpin2
acarpen5  bherrin2   comeaubk  dshadeck  hhabelt     jjohns43  jwilso39  mbonacke  nwebb       ryoung12  thakes3
acrocker  bhuffner   cpainter  dsherbur  hps1        jjohnst8  jwood36   mbrigham  oppenheim   sblake3   thatcher
adexter   bkenne11   critten1  dshreve   hramsey     jkingsle  jzimmer5  mbw6      pclose      sc000826  tjohns22
adilaur1  bkrishe3   csit2310  dstorm3   hshaikh     jkremer1  kamakazi  mcantin3  pcremidi    sclayton  tkane1
aettenb3  bnichol7   csleve    dtalvi    hwarren1    jlantz4   kbell1    mclark35  pdowd       sedward9  tkiser
afassett  bobpauljr  cspenc12  dtaylo15  ian         jlazaar   kboe      mcooper6  plindsa1    sjankows  tl009536
agardin4  bort       csteve16  dtennent  imaye       jluedema  kc017344  mdecker3  pm004968    sjelliso  tmizerak
ahazen    bowlett1   cwagner1  dtravis4  jandrew9    jm010967  kcard2    mdittler  pmcconn1    skinney1  tmong
ajernig2  brian      cwilder1  dwalrat1  javery9     jmanley3  kcaton    mearley1  qclark      smacombe  tp001498
ajoensen  brobbin4   cwoolhis  dwells6   jbaez       jmille59  kcook6    mfailing  radams4     smalik2   triley2
alius     bstoll     darduini  dwrigh18  jbamper     jmitch22  kcornel6  mfaucet2  rberry3     smatusic  ts004985
amorich1  btaber2    dates     eberdani  jbarne13    jmunson   kdenson   mgough    rbuchan7    smclaug3  vcordes1
anarde    bwheat     db010905  efarley   jbesecke    jmyers7   kgarrah1  mguthri2  rcaccia1    smd15     wag2
anorthr3  bwilso23   dchilso3  egarner   jblaha      jo009612  kgaylord  mhenry9   redsting3d  smilfor3  wedge
anowaczy  bwilson3   dcicora1  egleason  jblanch1    jpettie   kinney    mkellogg  reedkl      spetka    wezlbot
ap016986  cacquah    ddragoo   emorris4  jbrant      jphill17  kkrauss1  mkelsey1  rfinney2    spline    wfischba
appelthp  cas21      dfoulk1   en007636  jbrizzee    jr018429  klynch3   mmatt     rglover     squires   wknowle1
aradka    caustin8   dgirard3  erava     jburlin1    jrampul1  kpryslop  mowens3   rhender3    squirrel  wroos
aromero   ccaccia    dh002925  erebus    jc006215    jsabin1   kreed11   mp018526  rhensen     srk3      ystebbin
as012495  ccarpe10   dh018304  eryan3    jcardina    jschira1  kscorza   mpage9    rj005436    srog      zlittle
ascolaro  cchandan   dherman3  estead    jcavalu3    jshare1   ksisti2   mpaul6    rjohns41    ssmith85  zmccann
asmedley  ccranda2   dlalond1  eveilleu  jcosgro4    jshort6   kwalker2  mpresto4  rkapela     sswimle1  zward
asowers   cderick    dm005264  ewester1  jdavis34    jsmit176  lburzyns  mshort3   rlott       strego
astrupp   cdewert    dmagee3   ezajicek  jdawson2    jstrong4  lcrowley  mtaft4    rm002127    svrabel
atoby     cforman    dmay5     fclark1   jdrew       jsulli34  ld010818  mwagner3  rmatsch     swarren4
atownsle  cgoodwin   dmckinn2  gc007950  jeisele     jsulliv3  leckley   mwarne11  rmoses      sweller5
atreat2   ckelce     dmurph14  gcalkin3  jellis15    jt011443  lgottsha  mwitter3  rnewman     swilli31
awalke18  ckuehner   dpadget8  ggamarra  jferrito    jtongue2  lh000592  nandre    rosenbll    syang
bblack1   clawren2   dparson3  gr015546  jfrail      jtreacy   lhubbar3  nbaird    rpage3      synack
bboaz     cmace1     dpotter8  groush1   jfurter2    jtripp    llaughl3  nblancha  rpetzke1    ta018998
bbrown17  cmahler    dprutsm2  gsnyder   jh001093    jv001406  lleber    ngraham2  rraplee     tcolli12
lab46:/home$ 

unix Keyword: Current working directory

Definition

A current working directory to me is a folder a person has created and uses for files depending on the purpose of the folder and can access with cd issued commands and can change permissions on files inside of the folder.

Demonstration

Here is a current working directory of my own:

lab46:~$ cd src/cprog
lab46:~/src/cprog$ ls
bigNum    cipher.c      file      ftypes     functions.c  icprog    linkedlist.h  out.txt    prog1x5.c  prog4         prog5    prog6.c  prog8         prog9    test.c  var2
bigNum.c  cipher.txt    file.c    ftypes.c   hint1        icprog.c  message.in    plain.txt  prog3      prog4.c       prog5.c  prog7    prog8.c       prog9.c  var1    var2.c
cipher    decipher.txt  file.txt  functions  hint1.c      key.txt   nofile.txt    prog1x5    prog3.c    prog4.c.save  prog6    prog7.c  prog8.c.save  test     var1.c
lab46:~/src/cprog$ ls -l
total 268
-rwxr-xr-x 1 jpettie lab46  9521 Mar  1 21:05 bigNum
-rw-r--r-- 1 jpettie lab46  1832 Mar  1 21:05 bigNum.c
-rwxr-xr-x 1 jpettie lab46  9452 Feb 28 14:20 cipher
-rw-r--r-- 1 jpettie lab46  2323 Mar  1 19:55 cipher.c
-rw-r--r-- 1 jpettie lab46    34 Feb 24 20:04 cipher.txt
-rw-r--r-- 1 jpettie lab46    34 Feb 28 17:44 decipher.txt
-rwxr-xr-x 1 jpettie lab46  7481 Feb  7 16:48 file
-rw-r--r-- 1 jpettie lab46   372 Feb  7 16:48 file.c
-rw-r--r-- 1 jpettie lab46    15 Feb  7 16:45 file.txt
-rwxr-xr-x 1 jpettie lab46  8275 Mar  1 15:18 ftypes
-rw-r--r-- 1 jpettie lab46  1007 Mar  1 16:10 ftypes.c
-rwxr-xr-x 1 jpettie lab46  8058 Feb 24 15:09 functions
-rw-r--r-- 1 jpettie lab46  1061 Feb 24 11:55 functions.c
-rwxr-xr-x 1 jpettie lab46  7754 Feb 27 11:58 hint1
-rw-r--r-- 1 jpettie lab46   692 Feb 28 10:43 hint1.c
-rwxr-xr-x 1 jpettie lab46  7136 Feb 16 16:14 icprog
-rw-r--r-- 1 jpettie lab46   481 Feb 16 16:30 icprog.c
-rw-r--r-- 1 jpettie lab46    19 Feb 24 21:48 key.txt
-rw-r--r-- 1 jpettie lab46   509 Mar  1 21:01 linkedlist.h
-rw-r--r-- 1 jpettie lab46    42 Feb 27 09:57 message.in
-rw-r--r-- 1 jpettie lab46     0 Mar  1 23:42 nofile.txt
-rw-r--r-- 1 jpettie lab46    14 Feb  7 16:48 out.txt
-rw-r--r-- 1 jpettie lab46     0 Mar  1 23:42 plain.txt
-rwxr-xr-x 1 jpettie lab46 11673 Mar  1 23:42 prog1x5
-rw-r--r-- 1 jpettie lab46  1165 Mar  1 23:42 prog1x5.c
-rwxr-xr-x 1 jpettie lab46  6771 Jan 31 15:07 prog3
-rw-r--r-- 1 jpettie lab46   267 Jan 31 15:07 prog3.c
-rwxr-xr-x 1 jpettie lab46  7031 Jan 31 16:02 prog4
-rw-r--r-- 1 jpettie lab46   452 Jan 31 16:02 prog4.c
-rw-r--r-- 1 jpettie lab46   300 Feb 14 12:17 prog4.c.save
-rwxr-xr-x 1 jpettie lab46  7039 Jan 31 16:36 prog5
-rw-r--r-- 1 jpettie lab46   246 Feb  2 11:07 prog5.c
-rwxr-xr-x 1 jpettie lab46  7738 Feb  2 15:42 prog6
-rw-r--r-- 1 jpettie lab46   589 Feb 16 16:58 prog6.c
-rwxr-xr-x 1 jpettie lab46  7453 Feb  7 16:24 prog7
-rw-r--r-- 1 jpettie lab46   338 Feb  7 16:24 prog7.c
-rwxr-xr-x 1 jpettie lab46  7632 Feb 14 14:31 prog8
-rw-r--r-- 1 jpettie lab46   458 Feb 28 10:56 prog8.c
-rw-r--r-- 1 jpettie lab46   459 Feb 14 12:17 prog8.c.save
-rwxr-xr-x 1 jpettie lab46  6965 Feb 14 15:40 prog9
-rw-r--r-- 1 jpettie lab46   384 Feb 28 11:06 prog9.c
-rwxr-xr-x 1 jpettie lab46  7465 Feb 24 21:46 test
-rw-r--r-- 1 jpettie lab46   484 Feb 24 21:46 test.c
-rwxr-xr-x 1 jpettie lab46  6786 Jan 26 15:49 var1
-rw-r--r-- 1 jpettie lab46   305 Jan 26 15:49 var1.c
-rwxr-xr-x 1 jpettie lab46  6794 Jan 26 16:41 var2
-rw-r--r-- 1 jpettie lab46   256 Jan 26 16:41 var2.c
lab46:~/src/cprog$

unix Keyword: Text Processing

Definition

The way I think of Text Processing is a technique or device used to edit, and save text into files or from files but can also be used just on plain text as well to change it (for example: to change the color of text).

Demonstration

A tool used to process text I've used in the past and would be a good demonstration would be “nano”

lab46:~/src/cprog$ nano prog3.c 
#include <stdio.h>
 
int main(){
        int v = 17;
        int *p1 = NULL;
        printf("v is %u \n", v);
        p1 = &v;
        printf("*p1 is %u\n", *p1);
        *p1 = 53;
        printf("v is %u\n", v);
        printf("*p1 is %u\n", *p1);
        v = 7;
        printf("v is %u\n", v);
        printf("p1 is %u\n", *p1);
        return(0);
}

unix Keyword: Job Control

Definition

To me, Job Control is just another way of saying multitasking, but to multitask efficiently. To control the outcome and resources needed by each job to complete its task and to give the right results along with being able to run them both at the same time.

Demonstration

An example of Job Control to me, is using more than one windows in a screen session and having one be a tail to log files, and the other to run a bnetd file for a pvpgn server.

tail: invalid option -- *                                                                                              jpettie@lab46:~$ ssh root@vm31.student.lab
Try `tail --help' for more information.                                                                                Warning: Permanently added 'vm31.student.lab,10.80.3.31' (RSA) to the list of known hosts.
vm31:/usr/local/var# tail --help                                                                                       root@vm31.student.lab's password:
Usage: tail [OPTION]... [FILE]...                                                                                      Linux vm31 2.6.26-2-xen-686 #1 SMP Wed Sep 21 09:56:47 UTC 2011 i686
Print the last 10 lines of each FILE to standard output.
With more than one FILE, precede each with a header giving the file name.                                              The programs included with the Debian GNU/Linux system are free software;
With no FILE, or when FILE is -, read standard input.                                                                  the exact distribution terms for each program are described in the
                                                                                                                       individual files in /usr/share/doc/*/copyright.
Mandatory arguments to long options are mandatory for short options too.
      --retry              keep trying to open a file even if it is                                                    Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
                           inaccessible when tail starts or if it becomes                                              permitted by applicable law.
                           inaccessible later; useful when following by name,                                          Last login: Sat Mar  3 02:57:33 2012 from lab46.offbyone.lan
                           i.e., with --follow=name                                                                    vm31:~# cd /usr/local
  -c, --bytes=N            output the last N bytes; alternatively, use +N to                                           vm31:/usr/local# cd sbin
                           output bytes starting with the Nth of each file                                             vm31:/usr/local/sbin# ls
  -f, --follow[={name|descriptor}]                                                                                     bnetd  bntrackd  d2cs  d2dbs
                           output appended data as the file grows;                                                     vm31:/usr/local/sbin#
                           -f, --follow, and --follow=descriptor are
                           equivalent
  -F                       same as --follow=name --retry
  -n, --lines=N            output the last N lines, instead of the last 10;
                           or use +N to output lines starting with the Nth
      --max-unchanged-stats=N
                           with --follow=name, reopen a FILE which has not
                           changed size after N (default 5) iterations
                           to see if it has been unlinked or renamed
                           (this is the usual case of rotated log files)
      --pid=PID            with -f, terminate after process ID, PID dies
  -q, --quiet, --silent    never output headers giving file names
  -s, --sleep-interval=S   with -f, sleep for approximately S seconds
                           (default 1.0) between iterations.
  -v, --verbose            always output headers giving file names
      --help     display this help and exit
      --version  output version information and exit

If the first character of N (the number of bytes or lines) is a `+',
print beginning with the Nth item from the start of each file, otherwise,
print the last N items in the file.  N may have a multiplier suffix:
b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,
GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.

With --follow (-f), tail defaults to following the file descriptor, which
means that even if a tail'ed file is renamed, tail will continue to track
its end.  This default behavior is not desirable when you really want to
track the actual name of the file, not the file descriptor (e.g., log
rotation).  Use --follow=name in that case.  That causes tail to track the
named file by reopening it periodically to see if it has been removed and
recreated by some other program.

Report bugs to <bug-coreutils@gnu.org>.
vm31:/usr/local/var# tail -f .log
tail: cannot open `.log' for reading: No such file or directory
tail: no files remaining
vm31:/usr/local/var# tail -f *.log
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Emperor-2"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Red Alert 2-1"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Red Alert 2-2"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Nox Quest-1"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Yuri's Revenge-1"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Yuri's Revenge-2"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Lob 38 0"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Lob 39 0"
Mar 01 23:43:34 [info ] channel_destroy: destroying channel "Lob 40 0"
Mar 01 23:43:34 [info ] main: server has shut down

unix Keyword: Regular Expressions

Definition

When I think of Regular Expressions, I tend to think of if statements, comparing two things and seeing if they match, depending on type of course.

Demonstration

Here is a while statement to show Regular Expressions:

while (check == false){
    some sort of code to execute here
}

unix Objective

unix Objective

Exposure to command-line tools and utilities

Definition

In my own thoughts, I would consider the completion of this objective as using tools such as vi to accomplish a task, or even produce a program in c.

Method

The method I will use to show the completion of this objective is an example of vi editing of a program.

Measurement

Here is an example of vi after adding line numbers and syntax highlighting:

  1 #include <stdio.h>
  2 #include <stdlib.h>
  3 #include <stdbool.h>
  4
  5 int main(int argc, char **argv){
  6         int input;
  7         bool check = false;
  8         unsigned char i;
  9         while (check == false){
 10                 printf("Enter a value (0-4):");
 11                 scanf("%d", &input);
 12                 if (input > 4 || input < 0){
 13                         printf("You have entered an incorrect value.\n");
 14                         check = false;
 15                 }else{
 16                         for (i = 0; i < argc; i++){
 17                                 printf("argv[%hhu][%hhu]: %c\n", i, input, *(*(argv+i)+input));
 18                         }
 19                         check = true;
 20                 }
 21         }
 22         return(0);
 23 }
 24
Analysis

I believe I have showed use of a tool or utility from the command line. I think there is always room to grow, especially when you are running low on time and waited to long to complete your opus. The method seems pretty solid, it shows an example of a working tool. Employing this enhancement will work because the program will run. I believe the course objective is very vital and strong as it stands.

Experiments

Experiment 1

Question

What would happen if I were to try to install a package with aptitude that does not exist?

Resources

My resource can be completely by testing this on a command line interface.

Hypothesis

I believe there will be some sort of error that is spit back at you from aptitude based on trying to throw arguments at other commands that do not exist.

State your rationale.

Experiment

I am going to test my hypothesis by executing the command: aptitude install blahblahblah

Data

lab46:~$ aptitude install blahblahblah
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

Analysis

My hypothesis was not correct, because I got an error back not from aptitude but from another source. There is definitely more going on than I had conceived to begin with, I am getting a permissions error that I am not in root.

Conclusions

Based on the experiment, I can say that you cannot execute an aptitude install from a lab46 account that is not rooted.

Experiment 2

Question

Is there a way to use strings in the c language without using a library?

Resources

http://www.dfstermole.net/OAC/hstrings.html “In C, a string is stored as a null-terminated char array. This means that after the last truly usable char there is a null, hex 00, which is represented in C by '\0'. The subscripts used for the array start with zero (0). The following line declares a char array called str. C provides fifteen consecutive bytes of memory. N.B. Only the first fourteen bytes are usable for character storage, because one must be used for the string-terminating null.”

But this source showed an include of:

“#include <string.h>”

Hypothesis

Based on what I have read, I do not believe it is possible to use strings without an include file.

Experiment

To test my theory I will do more research and attempt to define a variable as type String.

Data

String x = "this is a string";

This code gave me an error that String is undefined. This leads me to believe that without the string include library, strings do not work in c as defined in other languages by the above.

Analysis

My hypothesis was correct, and the test examples show this.

Conclusions

I can get out of this experiment that to work with Strings in c, you have to include the String.h library.

Experiment 3

Question

Can the traffic of the irc between unix and csci be controlled by active users engaged in conversation?

Resources

For resources, I used a friend of mine from my hpc and c/c++ class named Josh to be the other active user in the irc to troll conversations with.

Hypothesis

I do believe that the irc traffic can be indeedly manipulated by active users by making conversation in only certain channels at different points in time.

To rationale this, we conducted conversations in different irc channels and the masses of the users seem to have flocked to those channels for help instead of the usual channels that the questions should be prompted in.

Experiment

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

Data

The data can be viewed through the many troll of such conversations in the irc logs.

Analysis

My hypothesis was correct, the masses of the users did change to channels that were more active to ask their questions in.

Conclusions

I can now, in conclusion, manipulate the irc channels with a friend in anyway possible, maybe even to take over the world! *Throws to bwammm sound on youtube from inception* http://www.youtube.com/watch?v=h4a3y7xetJY

opus/spring2012/jpettie/part1.txt · Last modified: 2012/03/02 23:10 by jpettie