OPUS TIME
With Harry and…yeah just Harry
My name is Harry Longwell, I am 20 years old, and I am going for Computer Science at Corning Community College.
Today I set up and learned how to use the class communication system. This will be a very useful tool for future projects and assignments. The problem that I am still having is navigating lab46.
Today I connected my mercurial repository with my bitbucket repository. This will make viewing my repositories much easier. Even still lab46 is giving me troubles.
I created the signed char, unsigned short int, and signed short int.
I created the signed int, unsigned int, signed long int, unsigned long int, signed long long int, and the unsigned long long int.
In Lab we tested our data type length program, mine had a few errors, hopefully these will be easy to fix.
Just watched the Binky Pointer Fun videos for C and C++. I suppose I understand the basic concept, but I think I'll need a hands on explanation to understand it fully. I'm a little worried about this class, both lecture and lab, and whether or not I'm going to understand the C language by the end of it.
In lecture today I made what believe to be a “Hello, World!” program and as a class we created a program that would test the char's of certain strings. Later that night I spent an hour looking at other peoples Opuses/Opi, trying to make whatever improvements I could. Some people have a lot of stuff that I would like to include in my own, but unfortunately I do not know how to do the things they did.
Today in C++ lab we discussed the sample pointer programs and specific parts of the code and the purposes that they serve.
Quote by Matt “Everything is pointers”
Topics discussed in lecture:
C declaration has two parts,
Array is a group of related values, group of memory, list of variable values, and an index for values
“=” is no longer know as a equal sign, it is now to be called an assignment.
Topics discussed in lab:
*(scores+2)=SCORE2;
is equivalent to scores[2]=SCORE2;
A new way to do comments is to use /*…*/
The “f” in “%f”
stands for float
%.2f
will output to only two decimal places
Quote by Matt: “Defines help with our sanity”
In C++ Lab we went over a few programs and went over want wasn't working and how to fix it. We specifically focused on the scanf()
command and what can go wrong when involved with other parts of the code. I learned the getchar()
and fgetc()
commands.
Today in lecture we began class by discussing “Things to do with characters/strings,” a list comprised of,
We also learned some new syntax,
= =
- is equal to!=
- is not equal to!
- not<
- less than>
- greater than⇐
- less than or equal to>=
- greater than or equal toIn lab we discussed “if”, “else”, and “else if” statements. We covered the subject of “block scope”. Basic if structure
int main() { int a; if(//condition//) { int b; } else { } }
.
Today in lecture we discussed the for
loop and its structure and uses. You use a for
loop when you already know how many times you are going to run the test. The basic structure of a for
loop is shown in the code below,
lab46:$ for (clause-1 ; expression-2 ; expression-3 ) {statement}
or
lab46:$ for (a=1; a<=10; a=a+2) { b=b+a; }
I also attempted to do the third and fourth projects for Joe's lecture. The third project is not functioning correctly, but I finished the fourth project.
Three types of loops,
Today in lab we went over the debugger. The following are some commands that are used for the debugger:
Today in lecture we discussed functions and their make up. All functions are composed of the same three things;
Functions also have three different steps;
Today in lab we used Matt's sample code to get an introductory look at how C can actually help to create visual images. This was very interesting because it was one of the first moments in the course where we have seen what C programming is really capable of. I look forward to more practice with programs like this.
Extremely angry at the moment. The following is the picture I made in lab March 22nd.
I would have liked to make changes to this but apparently the universe did not want me to be able to do that.
In lecture today we were working on how to link programs together so that you can have all your functions in one program to call upon. Today in Lab we worked on creating more images, this time using triangles. I made the following image
I have not updated my C programming opus in a very long time so I figured it was about time I added something. In lecture we have started doing a project where we are trying to create a hex editor. At first I did not enjoy the idea of this project, it did not seem to relate to anything of what we were doing or what we had learned so far. However, I now see the relevance of the project. It has been a good review of how to implement what we have learned, loops, arrays, etc.
In the lab portion of the class we have learned about such topics as, inheritance, polymorphism, GD library, and structs. Also we have started our end of class review, including a few assessments of our skills and what we have learned. I have currently completed the first program.
Lab 0*0: Introduction to UNIX/Linux and Lab46 This lab taught the basics that we will need to continue on in this class. Right now lab46 is pretty difficult to navigate and understand, but hopefully that will change overtime.
Started reading Unix for the Beginning Mage. I learned and practiced with new and familiar commands, including;
This was very helpful and I look forward to seeing what other commands this book can teach me.
I read the third chapter of Unix for the Beginning Mage. I have learned new commands, such as;
Finished Lab0X1. In this lab I was introduced to the commands ls, cp, mv, rm, and ln, and used them in certain exercises to become more familiar with how they worked and what they did. Some of these were more confusing than others and would seem to be important to have experience with before continuing on in UNIX.
I jest finished reading chapters 4 and 5 in Unix for the Beginning Mage. Chapter 4 was very simple and had some basic information on the different directories. Chapter 5 was a little more interesting and discussed the topic of “shielding” and through the follow along instructions I not only learned how to tell what kind of protection a file has, with ls -l, but also how to alter a file's protection, chmod.
Completed lab0x2, kind of. I was able to do most of what the lab was asking for, but there was a lot that I had no idea how to do, this includes; 2b, 4, and 11. I am going to need to seek out help.
Just finished the case study 0x1. For the first step I used the cp
command to copy files to my home directory. For the second section part “a” I used the gunzip archive1.tar.gz
and tar -xvf archive1.tar
commands for the “archive1.tar.gz” file and the unzip archive2.zip
command for the “archive2.zip” files. For part “c” I used the mv
command to rename the “abc.txt” file to “def.txt”. For the third section I used the tar -cvf arc.tar archives
command. Finally for the last section I used the gzip arc.tar
command to accomplish the final task.
Today I worked on the Case Study 0x2.
Using the *
wildcard I compressed the “compress “this” file.data” file, changed the name of the “change my\ name.file”, and use the cat
command to get some output from the “just a simple file.txt” file, and the output was the message “Simple, but simpler without the spaces!”
Using shell quoting I removed the “??? can you delete me ???.abc” and the “* watch out! *” files, used cat
to get output from the “( parenthesis & other odd things )” file, which was the message “Are we having fun yet?”, used the cat
command to get output from the “#pico28903#” file which was the message “laLAA… pretend this is a pico temp file”.
I have no idea what to do with the “$USER VALUE$”, “`ls` * HI! *”, and “one, 'two', three, “four”” files.
Today I started to work on Lab 0x3. I say started because I currently have no one to do part 5 with, I will document what I could do and the parts that seemed to jump out at me as being important.
In this lab I learned three new commands, holy crap.
For part 2a, I used the following code.
lab46:/etc$ wc -l passwd
To accomplish part 3a, I used the code found below.
lab46:/etc$ head -16 passwd
I used the following code for part 4a.
lab46:/etc$ tail -8 passwd
That was all that I could accomplish so far but I hope to finish the lab as soon as possible. Also I learned how to do code blocks, so now my Opus can look really cool and stuff.
Today I worked on case study 0x3 “The Puzzle Box.” I took notes on the parts that were new to me and are, what I feel to be, important to take note of. The only new command I learned from this case study was,
For part 1b, after using the file
command it is shown that the “file.txt” file is a ASCII text file, and after finishing part c, the file is indeed what it appears to be. For part e I am not sure if I did it correctly since the message seems to be the same as the one I received in part d. For the second section of the case study I got to part d but I am stuck at this point.
Today I worked on Lab 0x4. The new commands I learned are:
For section 3 of the lab it would seem that the “.bash_history” file records the commands entered into the prompt
For section 4, my Shell is /bin/bash
, my mail file is /home/hlongwe1/Maildir
, my termianl type is xterm
, and my path is /usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local/jave/bin
For section 8 I typed in the following command to recreate the alias
lab46:~$ alias ls="ls --color=auto"
This lab may be the greatest lab ever for the sole fact that it teaches “tab completion.”
Today I worked on Lab0x5 “More UNIX Shell Explorations”. This lab was a continuation of the exploration into the UNIX shell. The topics explored include; wildcards, I/O redirection, pagers, and quotes.
Section 1d: I used the following code to accomplish the task
lab46:~/src/unix/lab0x5/shell$ touch file1
Section 2a:
lab46:~/src/unix/lab0x5/shell$ ls file* file1 file1234 file2 file3 file4 file41 fileZZZ filea
Nothing is really different from a regular ls
b:
lab46:~/src/unix/lab0x5/shell$ ls file? file1 file2 file3 file4 filea
This is because it is matching only files with exactly one character
c:
lab46:~/src/unix/lab0x5/shell$ ls file[23] file2 file3
This is because it is displaying that match any of the enclosed characters
d:
lab46:~/src/unix/lab0x5/shell$ ls file[24a]*
This is because it is displaying that match any of the enclosed characters from 0 to more characters
Section 3a&d: I see that the logo from when first signing into Lab46 and then I see that plus “-This is text-” at the bottom after part “d”.
Section 4b&d: For part b it would seem that the new message is replacing was was previously in the file and for part d, it is searching for files that contain “file1” and storing them into “file2”
Section 5: I'm not sure if I did this correctly but I do not see any changes to “file2” at the end of this section
Section 7: For part a, it simply displays the current path. There were no changes for part b because the double quotes allow for variable expansion, but there were no more variables added so it was the same as the previous command. For part c the single quotes made $PATH a literal quote so when using the echo
command it simply got displayed.
Section 9:
lab46:~/src/unix/lab0x5/shell$ cat /etc/motd | wc -l 19
Today I worked on Case Study 0x5 “Web Pages.” In this case study I learned the following “tags”
At the end of the assignment I created my own custom web page with the URL “http://lab46.corning-cc.edu/~hlongwe1/harry.html,” it's some pretty great stuff.
Today I worked on Lab0x6 “Shell Scripting Concepts.”
Section 1:
a)
lab46:~/src/unix/lab0x6$ ls -l
c)
lab46:~/src/unix/lab0x6$ chmod u+x script.sh
Section 2:
echo "What is your birth year?" read date echo "So you were born in the year" $date let age=2013-$date echo "So that means you are" $age "years old"
Section 3:
#!/bin/bash pick=$((RANDOM %20)) echo "I am thinking of a number between 1 and 20. What is it?" read guess1 if ["guess1" -ne "$pick"]; then echo "Wrong, guess again(3 Remaining)" read guess2 if ["guess2" -ne "$pick"]; then echo "Wrong, guess again(2 Remaining)" read guess3 if ["guess3" -ne "$pick"]; then echo "Wrong, guess again(1 Remaining)" read guess4 if ["guess4" -ne "$pick"]; then echo "Wrong! You Lose!" else echo "Correct! You Win!" fi else echo "Correct! You Win!" fi else echo "Correct! You Win!" fi else echo "Correct! You Win!" fi
Section 4:
a)
#!/bin/bash for((i=1; i<=10; i++)); do echo -n "$i " done
b)
#!/bin/bash for((i=20; i>=2; i=i-2)); do echo -n "$i " done
For the remaining functions I had some problems. Section 5 my program does not work properly. For sections 6 and 7 I have no idea how to even start the program.
The following are the new commands that I learned,
Today I worked on Lab 0x8: The UNIX Programming Environment.
1)
lab46:~/src/unix/devel$ gcc -o helloC helloC.c
lab46:~/src/unix/devel$ g++ -o helloCPP helloCPP.cc
lab46:~/src/unix/devel$ as -o helloASM.o helloASM.S lab46:~/src/unix/devel$ ld -o helloASM helloASM.o
Then I simply used ./
before the compiled filename to run them
2) It does not work because just typing in “helloC” has the system interpreting it as a command. Having a ./
lets the system know to run a certain file.
3) “helloC.c” seems to be a code file. Running file
on the source files we see see that they are “ASCII C program text”, “ASCII C++ program text”, and “ASCII assembler program text”.
4)There is a new file “helloC.s”. The new file is “ASCII assembler program text”. “helloC.s” is ““helloC.c” converted into assembly language.
5) There is a new file “hello.o”. The new file is “ELF 64-bit LSB relocatable, x86-64, versiob 1 (SYSV), not stripped”. “hello.o” is “helloC.s” converted into object code.
7) For the file “hello” it says “ELF 64-bit LSB relocatable, x86-64, versiob 1 (SYSV, dynamically uses shared libs), for GNU/Linux 2.6.18, not stripped”, which matches “helloC”. The file runs, shown below.
lab46:~/src/unix/devel$ ./hello Hello, World!
Today I worked on case study 0x8 2)
3)
lab46:~/src/unix/devel$ gcc -o dtypes dtypes.c
4)
6) a) -32768 c)
#include <stdio.h> int main() { unsigned int a, x; signed short int b, y; a = 0; b = 32767; x = a - 1; y = b + 1; printf("signed short int before: %hd \t after: %hd\n", b, y); return(0); }
7)
#include <stdio.h> int main() { signed long long int a=0; printf("Before:\n-------\n"); printf("a address:0x%X\n:", &a); printf("a contains: %lld\n", a); a=a-1; printf("After:\n-------\n"); printf("a address:0x%X\n:", &a); printf("a contains: %lld\n", a); printf("The size of an signed long long int is %lld bytes", sizeof(a)); unsigned long long int b=0; printf("Before:\n-------\n"); printf("b address:0x%X\n:", &b); printf("b contains: %llu\n", b); b=b-1; printf("After:\n-------\n"); printf("b address:0x%X\n:", &b); printf("b contains: %llu\n", b); printf("The size of an signed long long int is %llu bytes", sizeof(b)); return(0); }
Today I worked on Lab 0x9: Pattern Matching with Regular Expressions.
For my searches with grep
I took a screen capture to show my results.
Today I continued to work on Lab0x9.
4a)
:%s/<centre>/<center>/g
b)
:%s/<b>/<strong>/g
c)
:%s/<\/centre>/<\/center>/g
d)
:%s/<\/b>/<\/strong>/g
5a)
lab46:/usr/share/dict$ cd /etc/dictionaries-common lab46:/etc/dictionaries-common$ ls -l total 4 lrwxrwxrwx 1 root root 28 Jan 19 2011 default.aff -> /usr/lib/ispell/american.aff lrwxrwxrwx 1 root root 29 Jan 19 2011 default.hash -> /usr/lib/ispell/american.hash -rw-r--r-- 1 root root 27 Jan 19 2011 ispell-default lrwxrwxrwx 1 root root 32 Jan 19 2011 words -> /usr/share/dict/american-english lab46:/etc/dictionaries-common$ cd /usr/share/dict/ lab46:/usr/share/dict$ ls -l total 920 -rw-r--r-- 1 root root 199 Jan 12 2011 README.select-wordlist -rw-r--r-- 1 root root 931708 Mar 30 2009 american-english lrwxrwxrwx 1 root root 30 Jan 19 2011 words -> /etc/dictionaries-common/words lrwxrwxrwx 1 root root 16 Jun 23 2010 words.pre-dictionaries-common -> american-english
The link's destination is the “american-english” file.
5b) It is a list of words
5c)
lab46:/usr/share/dict$ wc -w american-english 98568 american-english
6a)
lab46:/usr/share/dict$ grep '^.....$' american-english | wc -l 6685
6b)
lab46:/usr/share/dict$ grep '^[hwl]$' american-english | wc -l 3
6c)
lab46:/usr/share/dict$ grep '^h*[w]*l$' american-english | wc -l 1
6d)
lab46:/usr/share/dict$ grep '^[aeiou].*[aeiou]$' american-english | wc -l 1731
6e)
lab46:/usr/share/dict$ grep '^[hwl][aeiou].*[est]$' american-english | wc -l 4059
6f)
lab46:/usr/share/dict$ grep '^[^hwl].*$' american-english | wc -l 90815
6g)
lab46:/usr/share/dict$ grep '^[^th]..$' american-english | wc -l 764
6h)
lab46:/usr/share/dict$ grep '^..[e]$' american-english | wc -l 72
6i)
lab46:/usr/share/dict$ grep '^.*bob.*[^b]$' american-english | wc -l 41
6j)
lab46:/usr/share/dict$ grep '^blue.*$' american-english | wc -l 37
6k)
lab46:/usr/share/dict$ grep '^[^aeiouy]*$' american-english | wc -l 308
6l)
lab46:/usr/share/dict$ grep '^[^aeiouy].[abcd].*[aeiou]$' american-english | wc -l 1549
I also worked on Case Study 0x9
1a&1b)
lab46:~/src/unix/cs0x9$ grep 'coast' pelopwar.txt | wc -l 9
1c&1d)
lab46:~/src/unix/cs0x9$ grep '\<coast\>' pelopwar.txt | wc -l 8
1e)
lab46:~/src/unix/cs0x9$ grep 'Dorian$' pelopwar.txt | wc -l 1
1f)
lab46:~/src/unix/cs0x9$ grep '^Again' pelopwar.txt | wc -l 2
2a)
lab46:~/src/unix/cs0x9$ grep '^Athens' pelopwar.txt | wc -l 3 lab46:~/src/unix/cs0x9$ grep '^Athenians' pelopwar.txt | wc -l 5
2b)
lab46:~/src/unix/cs0x9$ egrep '(^Athens|^Athenians)' pelopwar.txt | wc -l 8
2c)
lab46:~/src/unix/cs0x9$ grep 'Corinth$' pelopwar.txt | wc -l 2 lab46:~/src/unix/cs0x9$ grep 'Corinthians$' pelopwar.txt | wc -l 5
2d)
lab46:~/src/unix/cs0x9$ egrep '(Corinth$|Corinthians$)' pelopwar.txt | wc -l 7
3)
lab46:~/src/unix/cs0x9$ fgrep '^Athens' pelopwar.txt | wc -l 0
In “2a” I used regular expressions and since fgrep does not accept these it would not find anything
4a)
lab46:~/src/unix/cs0x9$ last | grep '^[hwl].*$'
4b)
lab46:~/src/unix/cs0x9$ lastlog | grep '^[e-g].*$' | head -n 4 | sort en007636 pts/12 portal.corning.c Tue Jul 10 12:58:51 -0400 2012 fetchmail **Never logged in** games **Never logged in** gnats **Never logged in**
Today I worked on “Lab0xA: Data Analysis with Regular Expressions and Scripting”. Below I have taken notes on the more difficult aspects of the lab.
1a)
lab46:/var/public/unix/courselist$ cp fall2013-20130417.html.gz /home/hlongwe1/src/unix
1b)
lab46:~/src/unix/lab0xa$ ls -l total 80 -rw-r--r-- 1 hlongwe1 lab46 78062 Apr 17:46 fall2013-20130417.html.gz
1c) It is just a regular file since it has a ”-“ at the beginning of the file system permissions
1d)
lab46:~/src/unix/lab0xa$ gunzip fall2013-20130417.html.gz
1e)
lab46:~/src/unix/lab0xa$ ls -l total 2540 -rw-r--r-- 1 hlongwe1 lab46 2597201 Apr 17:46 fall2013-20130417.html.gz
2)
:/CSIT 2044
3)
:/crn_in=
4)
lab46:~/src/unix/lab0xa$ cat fall2013-20130417.html | grep '^<th.*crn_in=' | sed 's/^<th.*.....">//g' | sed 's/<\/a>.*<\/a>$//g' | sed 's/<\/a><\/th>//g' | less
5a & 5b)
lab46:~/src/unix/lab0xa$ cat fall2013-20130417.html | grep '^<th.*crn_in=' | sed 's/^<th.*.....">//g' | sed 's/<\/a>.*<\/a>$//g' | sed 's/<\/a><\/th>//g' | less | wc -l 1207
5c & 5d)
lab46:~/src/unix/lab0xa$ cat fall2013-20130417.html | grep '^<th.*crn_in=' | sed 's/^<th.*.....">//g' | sed 's/<\/a>.*<\/a>$//g' | sed 's/<\/a><\/th>//g' | less | grep 'CSCS' | wc -l 19
5e & 5f)
lab46:~/src/unix/lab0xa$ cat fall2013-20130417.html | grep '^<th.*crn_in=' | sed 's/^<th.*.....">//g' | sed 's/<\/a>.*<\/a>$//g' | sed 's/<\/a><\/th>//g' | less | grep 'ENGL 2' | wc -l 13
5g & 5h) The Math department has more classes
lab46:~/src/unix/lab0xa$ cat fall2013-20130417.html | grep '^<th.*crn_in=' | sed 's/^<th.*.....">//g' | sed 's/<\/a>.*<\/a>$//g' | sed 's/<\/a><\/th>//g' | less | grep 'ENGL' | wc -l 122 lab46:~/src/unix/lab0xa$ cat fall2013-20130417.html | grep '^<th.*crn_in=' | sed 's/^<th.*.....">//g' | sed 's/<\/a>.*<\/a>$//g' | sed 's/<\/a><\/th>//g' | less | grep 'MATH' | wc -l 127
The following is my work for Case Study 0xA: Data Manipulation
1a) The file permissions are different between the two files
1b) The size of the files is the same
1d)
howlong: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
1e)
lab46:/usr/bin$ ./uptime 21:20:39 up 102 days, 5:51, 11 users, load average: 0.40, 0.23, 0.23
1f)
lab46:~$ chmod u+x howlong lab46:~$ ./howlong 21:26:22 up 102 days, 5:56, 11 users, load average: 0.16, 0.25, 0.24