Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please can someone help me? I wish to know how to create a Bourne shell script i

ID: 3640925 • Letter: P

Question

Please can someone help me? I wish to know how to create a Bourne shell script in UNIX.

Here are the requirements for this assignment:
Create a Bourne shell script. The script should do the following:

1. Explain what the script will do and who is the author in a comment area.
2. cd to your home directory
3. Show your current working directory.
4. List the contents of the current directory.
5. Create the directory structure and create the files as defined in the previous Individual Project.
6. For each directory and file, test to see if the file or directory already exists; if it does exist, do not recreate; if it is missing, create it.
7. In the end, generate a directory listing showing the structure and content of the new directories.
8. At the beginning of the script, set a variable called INSTALL_DIRECTORY that will contain the location of the directory that the Web server will be installed into. At the end of the script, display the contents of this variable along with a message to the installer about the location that the directories were created in.
This is what I had to do in my previous assignment which will tie into the Bourne shell script as well.
Create 2 directories in your individual Home directory:
+- apache/
|
|- bin/
|
|- conf/
|
|- lib/
|
+- www/
|
| - html/
|
| - cgi-bin/
|
| - ftp/
The following file permission should be enabled for the directories:
1. The owner can read, write and execute All
2. The group can read and execute All Directories
3. Everyone else can only read and execute the files in Apache only (and no permissions in www)
4. Change the www tp directory to allow the User and group to read, write, and execute, but everyone else to only write to the directory
In addition, create the following empty files and set the following file permissions:
apache/bin/httpd - 755
www/html/index.html - 644
www/cgi-bin/process.pl - 711
Finally, create a file called apache/conf/httpd.conf, and add the following lines to the file:
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# Do not add a slash at the end of the directory path.
#
ServerRoot "/usr"
#
# DocumentRoot: The directory out of which you will serve your documents.
#
DocumentRoot "/Library/WebServer/Documents"
1. Save the file and exit the editor.
2. Set the file permission for this file to be: 664.
3. Show the command used to show content of the file and the content of the file.
4. Using the grep command, write comment to find the line containing the word(s) ServerRoot and DocumentRoot in the httpd.conf file.
5. Write a sed command that will change the ServerRoot value from /usr to the absolute directory patch for your apache directory.
6. Write a sed command that will change the Document value from /Library/WebServer/Documents to the absolute directory patch for your www directory.
7. Write an awk command that will print only the comment field and the login id of all users in the /etc/passwd file in this format: <Comment Field>

Explanation / Answer

Treat this as a series of problems, do the easier bits and work up to the harder ones. #!/bin/sh # ########################################… # Author: Emily 20-Dec-2011 # # # # Script to ...... etc # # ########################################… cd # go to home directory pwd # show current working directory There are the two basic requirements - as you can see, the first line never changes, then a comment block (with the # at the start of the line), then a couple of UNIX commands. To list the contents of the directory you just add another command, ls To add the variable (I'll leave the opening line and comment block out): INSTALL_DIRECTORY = "the_directory_path"; # to show the contents of the variable, use echo $INSTALL_DIRECTORY cd # go to home directory pwd # show current working directory ls # list current directory contents Okay, next step is to create a directory as defined in prev project - I'll assume it's called "prev_dir" and is going to be created in your home directory. First thing to do is test if it already exists: if [ ! -d "prev_dir" ] then mkdir prev_dir #doesn't exist, make it fi Okay, that's a start - follow the practice of learning how to do one bit before worrying about the next - it really does make life easier.