User Tools

Site Tools


opus:spring2012:smalik2:unixpart3

unix Keywords

17. Compiler, Assembler, Linker, Loader

Definition

The compiler takes the code and translates it into assembly code.

The assembler takes the assembly code and translates it into machine code - the resulting file being an object file.

The linker looks at the object file (which is linked to other object files and libraries, like the stuff from stdlib etc) and figures out how it all comes together, and assign memory locations to everything.

When it comes to load time, the loader creates a process and basically sets everything up for your program to run, and then launches into the instructions of your program.

Demonstration

It's possible to do these steps one at a time instead of letting gcc / g++ do it all for you. But it's rather painful.

g++ -c *.cc → will give you .o object files. These are compiled and assembled, so they are in machine code.

g++ -o Program *.o → This will link those object files, and give you a running program. yay!

18. Source Code, Object Code, Binary Code, Library

Definition

Source Code is the file that contains the code that you wrote.

Object Code is the file that contains the machine code, after the compiler and assembler are done with it.

Binary Code is the file that contains the machine code, and has been linked.

A library is a file that you can link to that contains many functions. There are math libraries, and then the standard libraries, etc.

Demonstration

We start with c source code files.
Then we translate them into object code files.
Then we finally link it all into a binary code file.
The last step also takes care of attaching the libraries I used and stuff.

lab46:~/src/cprog/projects/CProject2$ ls
Arrays.c  Functions.h  Math.c  Project2Monolithic.c
lab46:~/src/cprog/projects/CProject2$ gcc -c *.c
lab46:~/src/cprog/projects/CProject2$ ls
Arrays.c  Arrays.o  Functions.h  Math.c  Math.o  Project2Monolithic.c  Project2Monolithic.o
lab46:~/src/cprog/projects/CProject2$ gcc -o Program *.o
lab46:~/src/cprog/projects/CProject2$ ls
Arrays.c  Arrays.o  Functions.h  Math.c  Math.o  Program  Project2Monolithic.c  Project2Monolithic.o
lab46:~/src/cprog/projects/CProject2$ 

19. Pattern Matching

Definition

Pattern matching is the ability to find things that you're looking for, by using patterns to search for them.

Demonstration

Compiling a multifile program using patterns, instead of typing out a bunch of different file names.

lab46:~/src/cprog/c++/today$ ls
main.cc  rectangle.cc  rectangle.h  shape.cc  shape.h  square.cc  square.h  triangle.cc  triangle.h
lab46:~/src/cprog/c++/today$ g++ -c *.cc
lab46:~/src/cprog/c++/today$ ls
main.cc  rectangle.cc  rectangle.o  shape.h  square.cc  square.o     triangle.h
main.o   rectangle.h   shape.cc     shape.o  square.h   triangle.cc  triangle.o
lab46:~/src/cprog/c++/today$ g++ -o Program *.o
lab46:~/src/cprog/c++/today$ ./Program 
1 for Rectangle
2 for Square
3 for Triangle
2
You chose square. Enter the width/length: 12

The perimeter is: 48
The area is: 144

Einen schönen Tag noch, Ruck.

lab46:~/src/cprog/c++/today$ 

20. Regular Expressions

Definition

Regular Expressions, or RegEx, are algorithms that will match something.
By using these, you can search for, let's say, any word in a txt file that contains the gerund 'ing'.
It's pretty powerful stuff.

Demonstration

I have a file with a bunch of courses. Let's say I only want the Shortcut version (like, BUSN 0003 and FYEX 1000).

I can pipe the output through egrep which uses RegEx to match up to what I want.

The hard part, is coming up with the RegExp.

lab46:~/src/unix/courselist$ cat test.file
HIPAA - 77017 - BUSN 0003 - 001
Computer Keyboarding - 77015 - BUOT 1061 - 001
Word Processing for Non-Major - 77016 - BUOT 1062 - 001
Intro Graphical User Interface - 77002 - CSST 1031 - 001
OSHA Special Topics (30ct hr) - 77011 - ENVR 0030 - 001
Natural Gas Equipment Oper - 77014 - ENVR 0072 - 001
First Year Experience - 77005 - FYEX 1000 - 001
First Year Experience - 77004 - FYEX 1000 - 002
BasicLifeSupport-Prof. Rescuer - 77006 - HLTH 1010 - 001
BasicLifeSupport-Prof. Rescuer - 77007 - HLTH 1010 - 002
American History II - 77020 - HIST 1120 - 001
Achievement Motivation - 77021 - HUSR 1000 - 001
Care.&Aging Issue-Healthy Func - 77029 - HUSR 1411 - 001
Caregiving&Aging Issues-Common - 77030 - HUSR 1412 - 001
Lean Special Topic (24cnt) - 77012 - LEAN 0024 - 001
LEN Special Topic (57 cnt hr) - 77027 - LEN 0057 - 001
Excel Advanced Workshop - 77025 - EXCL 0004 - 001
Intro. to MasterCam Design - 77026 - MCAM 0113 - 001
Structures of Mathematics I - 77028 - MATH 1110 - 001
Medical Terminology - 77013 - MEDT 0030 - 001
Nurse Aide/Home Health Aide - 77022 - MDNC 0315 - 001
Child Abuse Recognition - 77023 - PDEV 0011 - 001
Child Abuse Recognition - 77024 - PDEV 0011 - 002
Child Psychology - 77010 - PSYC 2207 - 001
Abnormal Psychology - 77009 - PSYC 2215 - 001
Cross-Country Skiing (co-ed) - 77018 - RECC 1014 - 001
Wilderness Navigation - 77019 - RECC 1015 - 001
Introduction to Sociology - 77003 - SOCI 1010 - 001
The Vegetarian Adventure - 77008 - WELL 1011 - 001
lab46:~/src/unix/courselist$ cat test.file | egrep -o '[A-Z]?[A-Z]{3} [0-9]{4}'
BUSN 0003
BUOT 1061
BUOT 1062
CSST 1031
ENVR 0030
ENVR 0072
FYEX 1000
FYEX 1000
HLTH 1010
HLTH 1010
HIST 1120
HUSR 1000
HUSR 1411
HUSR 1412
LEAN 0024
LEN 0057
EXCL 0004
MCAM 0113
MATH 1110
MEDT 0030
MDNC 0315
PDEV 0011
PDEV 0011
PSYC 2207
PSYC 2215
RECC 1014
RECC 1015
SOCI 1010
WELL 1011
lab46:~/src/unix/courselist$ 

21 Filtering

Definition

Filtering is basically a program that gets data from standard input and then writes results to standard output. Like running grep on the cat from a file.

Demonstration

So, cat on a file outputs that files contents to standard output. If I pipe this to grep, grep will accept that standard input (that was output from cat) and then return it's answer to standard output.

Here we are printing a .html file to standard output, finding all the instances of CSCS, and then counting how many times that CSCS appears.

lab46:~$ cat fall2011-20110417.html | grep -o 'CSCS' | wc -l
51
lab46:~$ 

22. networking, UNIX Networking Tools

Definition

We never really went into networking with UNIX. It's such a broad topic that I don't really know how to get into it either.

Demonstration

23. Security

Definition

In UNIX/Linux the way that the system is set up provides good security by itself.

Since all files have permissions, just setting up the system to provide the correct permissions to the correct users ensures that the wrong people can't get their hands on files they shouldn't.

Taking advantage of the root-group-owner permission system is a great way of providing security in a multi-user system.

On top of it all, UNIX/Linux systems don't really have many viruses to begin with. All the viruses created target Windows and occasionally OS X.

Demonstration

24. X Window System

Definition

The X Window System is a software system that provides a GUI basically.

It has a very strong UNIX/Linux philosophy operating behind it.

It's designed to accept added functionality, and leaving it up to the user to determine what they want to do with it.

Demonstration

unix Objective

unix Objective

understanding and use of pattern matching

Definition

It's pretty straight forward. This means that we can use tools like grep, or even understand the syntax for searching for patterns instead of specifics using things like ls

Method

How well I utilize regexp.

Measurement

After struggling through the labs related to pattern matching and regexp and grep and all that good stuff, I feel pretty confident in my ability to use patterm matching.

Analysis

  • How did you do? Good
  • Is there room for improvement? Oh yes, I still struggled with finding a solution at a glance.
  • Could the measurement process be enhanced to be more effective? Not really, it's pretty easy to test it.
  • Do you think this enhancement would be efficient to employ? N/A
  • Could the course objective be altered to be more applicable? How would you alter it? Not really. maybe specify regexp.
opus/spring2012/smalik2/unixpart3.txt · Last modified: 2012/05/09 21:24 by smalik2