Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 3 : ThAssignment 5 : Monitoring tools: an introduction to some of the UNIX administrative commands. In this exercise follow the directions for Assignments

Assignment 3: ThAssignment 5: Monitoring tools: an introduction to some of the UNIX administrative commands.
In this exercise follow the directions for Assignments 1 and 3, Part 1. When a question is asked, put your answers in a file called: admin.docx. For answers consult the man pages and any other Internet sources you can find. Also append to this file the results of doing the following UNIX command-line steps on the lxcluster. Bear in mind that different UNIX systems will use variants for administrative come directions are similar to Assignment 1, above.
Part 1:
Step 0:
Enter the umask (1) command to determine your file creation mask; if not 0022, then set the umask to 0022.
Create a directory (in a convenient place it will be removed later) called temp
Execute the ls l command and note the permissions on the new directory; compare to the file creation mask above
Change directory to temp
Create an empty file (called newfile.txt) with the shell command: $ >newfile.txt
Execute the ls l command and note the permissions on the new file; compare to the file creation mask above
Step 1:
Change directory to the parent (with $ cd ..)
Attempt to remove the temp directory; note the failure message
Change directory back to temp
Change the permissions on newfile.txt (using chmod) to make the file writable by the group
Execute the ls l command to confirm
Change the permissions on newfile.txt to make it executable by the owner; execute the ls l command to confirm
Execute the newfile.txt (with the ./newfile.txt command); note that nothing happens (as it is empty)
Delete the newfile.txt file
Step 2:
Create a shell script file (called testscript.sh) and add the following commands to it.(The first line is a comment and instructs the shell to use the bash shell):
#!/bin/bash
echo listing
ls l
echo process status
ps
Make the testscript.sh file executable and readable by the user, the group, and others, but only writable by the owner; execute ls l to confirm
Run the script using the ./testscript.sh command
Step 3:
Create a new file called hardlink.txt with some text in it
hard link this file to a file called newfile.txt file (using the ln (1) command WITHOUT the s; see the man page for ln and get the order right!); confirm with ls -l
Confirm that the two files have the same inode number with the ls i * command
Remove (with the rm command) the hardlink.txt file; confirm with the ls li command that newfile.txt is still around with the same inode number
Create a file called simlink.txt symbolically linked (using the ln s command) to newfile.txt; confirm using ls l (note that symlink.txt is NOT empty and does NOT have the same number of bytes as the newfile.txt)
execute the command: cat symlink.txt to verify that it has the same contents as newfile.txt
Remove the newfile.txt file; confirm with ls l
Execute the following command to determine symlink.txts status: file symlink.txt
Remove all files in the temp directory interactively using the rm i * command; confirm with ls -l
Change directory to the parent directory and remove the temp directory; confirm with ls l
Part 2:
Write a program using the standard library I/O functions (fopen, fread, fwrite, fclose, ferror, feof, and fflush) to read a text file and search it for a string (specified on the command line) in each line of an input file (whose name is also specified on the command line); if the string is found substitute another string (also specified on the command line) ONLY ONCE on the line.
Write the output with the substitutions to the stdout and write any errors to the stderr. The command line should have the form:
assign03 infilename string1 string2
Be sure to check that the argc before proceeding.
So, for the command:
assign03 infilename test TESTED
where the infilename file contains:
This is a test file
for assignment 2.
It is to be tested thoroughly.
It substitutes a string for another uniformly
while reading a file opened
via the standard library.
And this is another test for testing.
Then the output to the stdout should be:
This is a TESTED file
for assignment 3.
It is to be TESTEDed thoroughly.
It substitutes a string for another uniformly
while reading a file opened
via the standard library.
And this is another TESTED for testing.
3 substitutions made
Note that the second occurrence of test (in the word testing) is NOT substituted.
You will want to read the input file one line at a time (into a buffer), and then search the buffer for the first occurrence of string1(if any); you may want to make use of strncmp (3). You do not have to open an output file in your program; if you write the substituted text to the stdout you can save its output in a text file with a command like:
$ assign03 infilename string1 string2> outfilename
In addition, keep a count of the total number of substitutions made and display that number on the stderr at the end of execution.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions