Lab Assignment 6 – Part 1 – In-Lab

$24.99 $18.99

Purpose: Learn how to correct a shell script and write more complicated shell scripts. Part 1: In order to finish the tasks in this lab, you must connect to snowball server to copy my checkError.sh $cp /home/yye10/public/checkError.sh checkError.sh In Lab 5, you may have tried the shell script checkError.sh in part However, there are four…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Purpose: Learn how to correct a shell script and write more complicated shell scripts.

Part 1:

In order to finish the tasks in this lab, you must connect to snowball server to copy my checkError.sh

$cp

/home/yye10/public/checkError.sh

checkError.sh

In Lab 5, you may have tried the shell script checkError.sh in part

  1. However, there are four errors on four different lines in that shell script. Please correct all the four errors by writing down the line number, the error and the correction as below:

Line #: Error: Correction:

Note: please use cat -n to check the line numbers.

$#/bin/bash

/* Check Error Script */

echo “Try to find out some errors!!!”

  • Seach for the words which can be matched by regex [^a]*ce

  • And save the output to file “Result”

echo “The regex [^a]*ce can match the string(s):” > Result grep ‘^[^a]*ce$’ << END >> Result lance

ace

brace

decide

piece

-ENDHERE

  • Check the existence of file “Result”

  • Send the content in “Result” to your emailbox

  • $1 is replaced by your campusID

ls

mail $1@student.gsu.edu <

Result

# $1

is

replaced by your campusID

echo

“The result has been sent

to ${1}@student.gsu.edu”

echo

“Congratulations! You have corrected all the errors!”

Hints:

Following is a sample of the output once all the errors are

corrected $ ./checkError.sh ylong4

Try to find out some errors!!!

checkError.sh Result

The result has been sent to ylong4@student.gsu.edu Congratulations! You have corrected all the errors!

You would also receive an email sent from your snowball account once all the errors are corrected.

You may need to use CTRL-C to terminate the execution of the command, especially for the script file with errors.

Part 2:

Write a single shell script hello.sh which can finish the list of tasks as below:

    1. Greet user. E.g. Welcome to computer science society.

    2. Contain a comment section with your name, and email address.

    3. Print the date.

    4. Print the number of directories in /home .

    5. Print the value of variables PATH, USER and SHELL.

    6. Print your disk usage (df).

    1. Print Please, could you loan me $25.00?

    2. Print if x = 2, x * x = 4 , x / 2 = 1

    3. List all the .sh files with c at the beginning of the file name in current working directory.

  1. Tell the user Good bye and the current hour (see manual page of date command refer to the webpage at http://www.thegeekstuff.com/2013/05/date-command-examples )

Include the content of hello.sh in your answer sheet. Besides, please also upload hello.sh as a separated file.

Upload your answer sheet to the folder named “Lab 6_P1” of the dropbox in the iCollege system. Name your file in the format of Lab6_P1_FirstnameLastname.pdf/doc

Hints:

When printing out strings using echo, to escape the special meaning of the meta-character, please use back slash \ before the meta-character.

To share files between remote server and the host machine, we can use FileZilla – A FREE FTP. The link to download this application is https://filezilla-project.org/download.php

Lab Assignment 6 - Part 1 - In-Lab
$24.99 $18.99