BÝLKENT UNIVERSITY
DEPARTMENT OF COMPUTER TECHNOLOGY AND PROGRAMMING
CTP203 Operating Systems Spring 2000 Lab Midterm |
Name/Surname: |
Instructor : Can Uður Ayfer Assistant : Ece Yargý |
Date : 20 May 2000 12:00 |
Please read the questions carefully. Attempt ALL the questions. Each question is 10 pts. There are 10 questions on four pages
1 |
What is the UNIX “ who” command used for?
|
2 |
What does the following UNIX cp command do?cp /usr/local/bin/w* |
3 |
Suppose you have logged on to host “gunes” as user “cayfer” and you have the following files (listed by the “ls –l” command) in your home directory:-rw-r--r-- 1 cayfer 16188 Feb 15 19:56 listserver.pl Please indicate CLEARLY which of the following stements are TRUE and which of them are FALSE.
|
4 |
Suppose you have logged on to host “gunes” as user “cayfer” and you have the following files (listed by the “ls –l” command) in your home directory:-rw-r--r-- 1 cayfer 16188 Feb 15 19:56 listserver.pl Please indicate CLEARLY which of the following stements are TRUE and which of them are FALSE. |
5 |
Suppose you have written a C program and entered its source to a file called “ myprog.pl”. To run this program; (Please indicate CLEARLY which of the following stements are TRUE and which of them are FALSE.) |
6 |
|
7 |
What does the the “cat *.txt | less” command do?
|
8 |
Suppose you have logged on to host “gunes” as user “cayfer” and you have the following files (listed by the “ls –l” command) in your home directory:-rw-r--r-- 1 cayfer 16188 Feb 15 19:56 listserver.pl
If you want to delete everything (files and directories) under this directory; you must use the UNIX command: |
9 |
Suppose you have a text file (“ctp203_list_of_students.txt”) which contains a list of 3450 students registered to CTP-203 course. A few example lines out of this file looking like :
Which UNIX command would you use to display students who got an A+ in this course
|
10 |
The following PERL program is supposed to be executed by using exactly two parameters, file1 and file2, and should make sure file1 exists and file2 does not exist. If file1 exists and file2 doesn’t; then the program should copy file2 to file2. There are some errors in this program. You should find at least 8 errors to get 10 points for this question. You will get 5 points for 5-7 errors you find. No partial grade will be given for less than 5 errors you find. (Hints : The special variable $#ARGV contains the subscript of the last parameter and the array @ARGV contains the command line arguments.) # Program starts here. print "Incorrect number of arguments!\N": 2 exit; } # get the first and second arguments file2 = @ARGV[1]; 5, 6 # check whether they exist if ( ( -d $file1) && ( -f $file2)) { 7print FILE1 FILE2 "Error! $file1 does not exist or $file2 exists!\n"; 8 system; } open (INFILE, $file1); while (<INFILE>) { print OUTFILE $_; } print "Done\n";
1: Must compare against 1. $#ARGV is the subscript of the last argument and subscripts start at 0 in Perl. 2: Must use \n. Line must end with ; not : 3,5. scalar vars need a $. file1= … must be $file1 = … 4,6 : References to array elements must start with $ not @ (must be $file1=$ARGV[0]) 7: There is logic error here. Not syntax error. Must use the OR (||) operator instead of AND (&&). 8: print FILE1 FILE2 doesnot make sense. Neither FILE1 or FILE2 should be there! 9: To open a file for output the ">" redirector must be used. Should be open (OUTFILE, ">$file2"); 10: Logic error here. Should read (and already have done it) from INFILE. Console input is absolutely nonsense here. |