Starting from:

$20

CS5348-Operating Systems: Project 1 Solved

The goal of this project is to let you get familiar with the basic commands in Unix systems and learn how to write shell scripts. You can use any Unix shell language, such as Bourne shell (sh), C shell (csh), bash, to implement this project.

Similar to procedural programming languages, shell script languages also support the basic control constructs ifthen-else, while loop, foreach, etc. You can google to find tutorials for writing shell scripts. Some resources for this and subsequent projects are given at my web page:    https://personal.utdallas.edu/~ilyen/course/os/home.html

 

Shell ScriptsMakefile, pipe, and redirect
First, write a makefile for compiling the C source code files provided for the project (please see my web page given above). The generated executable should be named as “cal.exe”. 

Note that you may face problems with the compilation of the code (the code is correct) and you need to figure
out how to solve them. The code is correct and there is no need to change anything. When you compile each C
source code file separately (you are required to do so in your makefile), you need to use proper options for gcc
(or cc) to avoid complaints about undefined variables. Also, you need to figure out what other parts shall be
 
included in the compilation command to properly compile the code without getting error messages.
 
 

Next, write a shell script “exec.sh” to compile the program using the “make” command and execute cal.exe with provided input file “cal.in”. In script “exec.sh”, you need to capture the output from cal.exe and print it to a file with name 𝑓. In other words, your script needs to take 𝑓 as an input argument. Your shell script will need to execute cal.exe twice. In the second execution, you need to pipe the output of cal.exe to the “wc” command and append the output from wc command to 𝑓. 

Directory traversal
Write a shell script “traverse” to traverse the directory structure starting from a directory 𝑑, where 𝑑 is given as the input argument for your traversal script. During traversal, print out each directory you have visited on the screen. At the same time, for each directory traversed, print the directory name and the list of files in the directory (directories are also files) with file sizes less than 1KB to a log file 𝑙. 𝑙 will be the second input argument for traverse. 

About your scripts
Your shell scripts should allow anyone to run from any working directory (e.g., TA or instructor will download your submission from elearning and test your scripts in her/his directories). You need to test your scripts on a UTD Linux server, on which your scripts will be tested by the TA or the instructor. You can use putty to remote login and do the testing.

More products