Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

25 Questions on Networking III-Unix Based Networking - Exam | CSCI 553, Exams of Computer Systems Networking and Telecommunications

Material Type: Exam; Professor: Harter; Class: Networking III-Unix Based Ntwk; Subject: Computer Science - CSCI; University: Texas A & M University-Commerce; Term: Spring 2008;

Typology: Exams

Pre 2010

Uploaded on 08/18/2009

koofers-user-peb
koofers-user-peb 🇺🇸

5

(1)

10 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Name: ___Solutions__________________ SID: ____Solutions____________
CSci 414/553: Unix Network Prog & Software Development
Test 1, Spring 2008
Answer the following questions in the space provided, or as instructed by editing and adding files to your
student account. Please be write clearly and make clear your final solution to a question if you make changes or
corrections (pencils are recommended). Partial credit will be given if and where possible, so show your work
where appropriate. This test is open book / open source material, you may use any source materials you like
and find helpful for this class. However, this is an individual test, no cell phones, IM or other collaboration will
be allowed during the test.
For official grading use only. Total: ______/
100
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/6 /2 /4 /2 /3 /6 /3 /3 /6 /3 /2 /3 /3 /3 /1 /1 /1 /1 /6 /8 /5 /10 /2 /4 /12
1. (6 pts) Match the following tools/commands with the description of their purpose (you can draw lines
and/or match the number with the letter).
1) rm La) symbolic debugger 3
2) ls Hb) create or extract archives of directory structures 6
3) gdb Ac) concatenate files and print on standard output 7
4) grep Ed) task automation and system build tool 12
5) chmod Ie) print line matching a regular expression pattern 4
6) tar Bf) c source code compiler 8
7) cat Cg) revision control system 11
8) gcc Fh) list directory contents 2
9) man Ki) change file access permissions 5
10) cd Jj) change working directory 10
11) svn Gk) read online reference manuals 9
12) make Dl) remove files or directories 1
CSci 553, Test 1 1 Spring 2008
pf3
pf4
pf5
pf8

Partial preview of the text

Download 25 Questions on Networking III-Unix Based Networking - Exam | CSCI 553 and more Exams Computer Systems Networking and Telecommunications in PDF only on Docsity!

Name: ___Solutions__________________ SID: ____Solutions____________

CSci 414/553: Unix Network Prog & Software Development

Test 1, Spring 2008

Answer the following questions in the space provided, or as instructed by editing and adding files to your

student account. Please be write clearly and make clear your final solution to a question if you make changes or

corrections (pencils are recommended). Partial credit will be given if and where possible, so show your work

where appropriate. This test is open book / open source material, you may use any source materials you like

and find helpful for this class. However, this is an individual test, no cell phones, IM or other collaboration will

be allowed during the test.

For official grading use only. Total: ______/

/6 /2 /4 /2 /3 /6 /3 /3 /6 /3 /2 /3 /3 /3 /1 /1 /1 /1 /6 /8 /5 /10 /2 /4 /

1. (6 pts) Match the following tools/commands with the description of their purpose (you can draw lines

and/or match the number with the letter).

1) rm L a) symbolic debugger 3

2) ls H b) create or extract archives of directory structures 6

3) gdb A c) concatenate files and print on standard output 7

4) grep E d) task automation and system build tool 12

5) chmod I e) print line matching a regular expression pattern 4

6) tar B f) c source code compiler 8

7) cat C g) revision control system 11

8) gcc F h) list directory contents 2

9) man K i) change file access permissions 5

10) cd J j) change working directory 10

11) svn G k) read online reference manuals 9

12) make D l) remove files or directories 1

  1. (2 pts) Which of the following problems or tasks does a version control system like subversion solve for you? a) Allows you to automate repetitive tasks b) Allows multiple collaborators to share and sync changes with one another c) Allows you to undo changes in time, e.g. see the past history of changes done to a file d) Allows you to symbolically debug a program in a more systematic way than using print statements. Answer(s) (choose all that apply): ______ B, C ______________
  2. (4 pts) If you run the following subversion command and see this output: [harry@nisl lab04]$ svn status ! wc.py M palindrome.py A goodbye.py C reverse.py What does the! indicate about the wc.py file? ________ File is missing in local working copy of repository What does the M indicate about the palindrome.py file? File has been modified What does the A indicate about the goodbye.py file? ___ File has been added to repository What does the C indicate about the reverse.py file? ____ File is in conflict
  3. (2 pts) The pipe command ( | ) is used to: a) Redirect the output of a command into a new file b) Renumber the output of a command c) Run two commands concurrently d) Redirect the output of a command into the input of another command Answer(s) (choose all that apply): ___ D _____
  4. (3 pts) Given the following directory listing: [root@nisl sbin]# ls -al rrestore service lrwxrwxrwx 1 root root 7 Jun 26 2007 rrestore -> restore -rwxr-xr-- 1 root aturing 1744 Nov 28 2006 service What type of file is rrestore? ____ symbolic link __________________________ Who has permission to delete the service command file? _ root (the owner of the file) Who has permission to execute the service command? ___ root (the owner) and members of the aturing group
  5. (6 pts) Mark the following as examples of either Relative path names (R) or Absolute path names (A) a) test.py _ Relative _ b) ../../bin/script.py _ Relative _ c) /usr/local/lib/libabs.a _ Absolute _ d) ~/work/project/file.txt _ Relative _ e) / _ Absolute _

[user@nisl ~]$ make test1 is invoked? __ gcc -c -o test1.o test1.c gcc -g -O2 -D_REENTRANT -wall -o test1 test1.o ../libunp.a -lpthread

  1. (3 pts) What is displayed when the following python script is run as shown: ----- argscript.py contents ----- #!/usr/bin/env python import sys for arg in sys.argv: print arg

[harry@nisl ~]$ ./argscript.py arg1 -flag1 arg ./argscript.py arg -flag arg

  1. (2 pts) We discussed and frequently used two special directory to specify relative path names from the command line and in Makefiles and scripts. Briefly, what do these two special directory names refer to? a). __ the current working directory ____________________________ b) .. the parent directory (relative to the current working directory)
  2. (3 pts) Briefly describe what each wildcard character does when used with the bash shell to match file names: a) * ____ match 0 or more of any character _______________________________ b)? ____ match any single characte r_____________________________________ c) [] ____ match any single character among choices (e.g. if [aeiou] match either an a, an e, an i, an o or a u)
  3. (3 pts) Given the following directory listing, what will be displayed by executing the given directory listing command: [dharter@chaos shultznn] $ ls -al total 120 drwxr-xr-x 2 dharter dharter 4096 2007-02-26 16:. drwxr-xr-x 9 dharter dharter 4096 2007-02-21 09: .. -rwxr-xr-x 1 dharter dharter 26541 2007-02-26 16:51 backpropsim -rw-r--r-- 1 dharter dharter 2020 2007-02-23 15:42 backpropsim.c -rw-r--r-- 1 dharter dharter 4440 2007-02-26 16:51 backpropsim.o -rw-r--r-- 1 dharter dharter 149 2007-02-23 15:35 Debug.h -rw-r--r-- 1 dharter dharter 13605 2007-02-23 15:38 Layer.c -rw-r--r-- 1 dharter dharter 617 2007-02-23 11:05 Layer.h -rw-r--r-- 1 dharter dharter 14044 2007-02-26 16:51 Layer.o -rw-r--r-- 1 dharter dharter 584 2007-02-26 16:50 Makefile -rw-r--r-- 1 dharter dharter 1834 2007-02-23 15:39 Pattern.c -rw-r--r-- 1 dharter dharter 392 2007-02-22 11:10 Pattern.h -rw-r--r-- 1 dharter dharter 5724 2007-02-26 16:51 Pattern.o -rw-r--r-- 1 dharter dharter 499 2007-02-21 11:14 Random.c -rw-r--r-- 1 dharter dharter 193 2007-02-21 11:55 Random.h -rw-r--r-- 1 dharter dharter 3140 2007-02-26 16:51 Random.o [dharter@chaos shultznn]$ ls [LP]*.[hc] Layer.c Layer.c Pattern.c Pattern .h
  1. (3 pts) What are the 3 I/O connections that every process in Unix has to the outside world when it is created, and what are these connected to by default (don't forget this second part, does the I/O go to a printer for example by default, or where)? a) _ standard input connected to the keyboard __ b) _ standard output connected to the terminal _ c) _ standard error also connected to the terminal
  2. (1 pts) The following use of pipes is illegal because you can only pipe 2 commands together at most: $ grep 'Title' spells.txt | sort | uniq -c | sort -n -r | head -10 > popular_spells.txt a) True b) False
  3. (1 pts) Any program that reads from standard input and writes to standard output can use I/O redirection and pipes a) True b) False
  4. (1 pts) A program that reads from standard input, does some manipulation, then writes results to standard output is called a: ____ Filter _______________ __________________________
  5. (1 pts) If you are using the bash shell, which file should you edit in order to have variables or aliases set automatically for you every time you log in? __ ~/.bashrc ________________________________________
  6. (6 pts) Assume that there is a subversion repository that you have modify access to at the url location http://magicco.org/repo What subversion command would you use to check out a working copy of the magicco repo to a directory calld magiccorepo in your home directory? [ user@nisl ~]$ svn co http://magicco.org/repo magiccorepo If you are now in the magiccorepo working copy directory, what command would you use to synchronize your working copy of the repository with the most recent revision that has been checked in? [ user@nisl ~]$ svn update What command would you run to add a new file named spells.txt in current directory to be under revision control? [ user@nisl ~]$ svn add spells.txt What command would you run to see all of the logged history of updates and changes to the repository? [ user@nisl ~]$ svn log What command would you use to remove a file named spellusers.txt that is currently under repository control from the repository? [ user@nisl ~]$ svm rm spellusers.txt
  1. (continued from question on previous page) What commands will be be run by make when we do the following. Be careful , you need to examine the dates/time stamps as well as the file dependencies to determine which commands will be run. Remember, that make will only run the actions for targets that are out of date based on their dependencies. [dharter@chaos tests]$ make dat2csv gold.dat > gold.csv dat2csv lead.dat > lead.csv # silver.csv is already up to date (newer) than its dependency, so will not be rebuilt) summarizecsv gold.dat lead.dat silver.dat > element_summary.csv Whoops, what is wrong with the make file that causes the following problem? How would you fix the problem? [dharter@chaos tests]$ make clean rm -v *.dat removed gold.dat' removedlead.dat' removed silver.dat' [dharter@chaos tests]$ make make: *** No rule to make targetgold.dat', needed by `gold.csv'. Stop. The clean target should remove product files, not source files: clean: *rm -v .csv
  2. (5 pts) In Python, what data type or data structure is held in each of the following variables. Possible answers include Boolean, String, List, Dictionary, Tuple, Integer, ImaginaryNumber, Function items = [1, 2, 3] __ List _________________ user = “Derek” __ String _______________ dates = {“newton”: 1942, “einstein”: 1882} __ Dictionary ___________ point = (8,2) __ Tuple ________________ flag = True __ Boolean ______________
  3. (10 pts) Given this variable assignment in python: vals = [5, 20, 8, “red”, “green”, “blue”] Write two versions of a Python loop that will print out each item in the variable on a separate line to standard output, one using indexes and one that doesn't use indexes. You should write this as a simple Python script, name the script loop.py, add it to your test directory in your repository working copy, and check the file in. Example solutions are available checked in to example student harry repository. Do a $ svn co http://nisl.tamu-commerce.edu/repo/csci553/harry/test harrytest to see the solution
  4. (2 pts) Given the following variable declaration in Python: element = “hydrogen”

What is displayed on standard output if we do the following (remember that it helps here to think of the indices as being between elements): print element[1:3], element[:2], element[4:-1] yd hg oge

  1. (4 pts) What is displayed after we execute the following Python statements: birthday = { 'Newton' : 1642, 'Darwin' : 1809, 'Turing' : 1912 } del birthday['Turing'] birthday['Einstein'] = 1888 names = birthday.keys() names.sort() for name in names: print name, birthday[name] Darwin 1809 Einstein 1888 Turing 1912
  2. (12 pts) The following should be done in your student account. Copy the test script called TestLastUpper.py from /home/csci553/classfiles/TestLastUpper.py, add it to your test directory of your repository working copy, and check it in when you have completed the question. You are to implement and test a function that accepts a single string as input, and returns a boolean result. The purpose of the function is to return true if the last (and only the last) character of the string is an upper case character. Currently the function does nothing, you need to provide the correct logic to implement the function as described. Once you have implemented your function you should test it. A single test is already available for you in the script which tests a typical example where the function should return True: isLastOnlyUpper('hellO') => True # test a true example Once your function is working, you should add tests for all of the following as well, and make sure your function works for all of these cases: isLastOnlyUpper('') => False # test the boundary condition of an empty string isLastOnlyUpper('a') => False # test false boundary condition single character string isLastOnlyUpper('A') => True # test true boundary condition single character string isLastOnlyUpper('HellO') => False # test a false example isLastOnlyUpper('hello') => False # a different failure case Example solutions are available checked in to example student harry repository. Do a $ svn co http://nisl.tamu-commerce.edu/repo/csci553/harry/test harrytest to see the solution