Question

In: Computer Science

In this lab, you will learn how to create shell scripts using the Bourne Shell Scripting...

In this lab, you will learn how to create shell scripts using the Bourne Shell Scripting language. The student will have to do research on the Bourne Shell Scripting language and then writ a script that asks the First Name , Last Name, Age, and Country of origin of the student and then print out these items in a statement Then the students will write a 3 to 4-page paper (not including the title and references pages) describing how the process was carried out in the lab

Solutions

Expert Solution

#BASH Script To ask the Details of the student and then print out in a statement
echo "Enter your first name"
read FIRST
echo "Enter your last name"
read LAST
echo "Enter your Age"
read AGE
echo "Enter your Country of origin"
read COUNTRY
echo "The details of the student are:
The Full name is $FIRST $LAST,
The age of the stdent is $AGE,
The country of origin is $COUNTRY. "

The above script is run to fulfill the requirements of this question. BASH stands for Bourne-Again Shell. It has multiple variable that are responsible to pick the values which are provided by the user. The above script begins with a comment that describes the function of the script which in this case was to use Bourne Shell Scripting language to write a script that asks the First Name, Last Name,Age and Country of origin of the student and then print out these items in a statement for the user to view it.

There are a few concepts of BASH that were used here such as Comment, Variable, echo, read.The name of the variable used are $FIRST $LAST,$AGE,$COUNTRY in the script that we have written. Here we notice that we don't need to pre-define these variables in the program we declare them when we need them which is the case for most of the scripting languages. The echo command is used to display line(s) of text to the console which is considered to be the output of the code. The echo command is a built in command in the BASH shell scripting scenario. Similarly, The read command is used to read input in the form text or string or numbers which is given by the user. So basically it takes input from the keyboard. The read command is a built in command in the BASH shell scripting scenario.


Related Solutions

CIT 371 Lab 12: shell scripting Start VMware, your VM and log in as Student. cd...
CIT 371 Lab 12: shell scripting Start VMware, your VM and log in as Student. cd to your home directory and create a subdirectory called scripts. cd to that directory. You can use gedit or some other editor but you need to get used to vi, so I strongly recommend that you use vi. Remember before running any new script that you will need to modify its permissions to be executable. Use either 745 or 755. Create a script called...
Create shell scripts, .sh file. Please include a shebang line at the top of the script...
Create shell scripts, .sh file. Please include a shebang line at the top of the script as well as appropriate comments through out. Write a script that plays a simple “guess the number” game with the user. It should select a random integer in the range [0 - 10], ask the user to guess the value, and provide feedback of the form “too high”, “too low”, or “congratulations” as appropriate. After the correct value is guessed, the script should terminate.
Create shell scripts, each in its own .sh file. Please include a shebang line at the...
Create shell scripts, each in its own .sh file. Please include a shebang line at the top of the script as well as appropriate comments through out. Write a script that reads sunspot data from data-shell/data/sunspot.txt and uses awk to print a list of the total number of sunspots for each year on record as well as the twelve monthly averages across the record. Note: "awk allows you to index arrays using strings, so as you traverse the data file,...
Learn by Doing Matched Pairs: In this lab you will learn how to conduct a matched...
Learn by Doing Matched Pairs: In this lab you will learn how to conduct a matched pairs T-test for a population mean using StatCrunch. We will work with a data set that has historical importance in the development of the T-test. Paired T hypothesis test: μD = μ1 - μ2 : Mean of the difference between Regular seed and Kiln-dried seed H0 : μD = 0 HA : μD > 0 Hypothesis test results: Difference Mean Std. Err. DF T-Stat...
Create a shell script called (Main.sh). The script must call the following scripts (FileS.sh), (Work.sh), (Ether.sh),...
Create a shell script called (Main.sh). The script must call the following scripts (FileS.sh), (Work.sh), (Ether.sh), (Arch.sh) and (Buzz.sh). The first script Main.sh must have two subroutines. The First Subroutine will display the following messages on the screen: 1-Display User login name, date and time. 2-Display System boot time. 3-Working path and Shell type 4-Display Home directory and number of files and directories in your Home. 5-Message describing briefly the requited tasks.
Task: 2.1 : Shell Scripting Task1 :Traditional hello world script Open terminal create Lab01 directory and...
Task: 2.1 : Shell Scripting Task1 :Traditional hello world script Open terminal create Lab01 directory and use cd command to move into the directory Open a new file script hello.sh using vi editor # vi hello.sh Type the following lines #!/bin/bash           echo Hello World     Save the file and return back to terminal How to Runhello.sh Adding Execute Permission Checking current permission        # ls -la hello.sh Adding Execute permission # chmod u+x hello.sh   Check whether execute permission is added # ls...
Simple shell scripting Write a Bash shell script called strcount.sh that counts the number of occurances...
Simple shell scripting Write a Bash shell script called strcount.sh that counts the number of occurances of a given string within a file. The scripts takes two arguments: the name of the file to check and the string to count occurances of. If the file is not found (or not readable), the script should print the error message Cannot access file and exit with code -1. Otherwise, the script should print the number of occurances of the given string and...
The Problem Statement In this lab section, you are going to learn how to sort an...
The Problem Statement In this lab section, you are going to learn how to sort an array of integers, and to sort an array of objects. We are going to divide the work into two parts. Part 1. Sorting an array of integers using selection sort In this part, you are given the code (see List 1) for sorting an array of integers into ascending order. The sorting method used is the selection sort. You can cut-and-paste the code into...
this is bash scripting. a. Write a shell script that adds an extension “.deb” to all...
this is bash scripting. a. Write a shell script that adds an extension “.deb” to all the files in a directory. b. Write a command sequence or a script to insert a line “GHIJKLM” at every 10th line of a file? c. Write a bash command or script to find all the files modified in less than 5 days and print the record count of each.
Can you write the shell scripts for these C files (code in C): #include <stdio.h> #include...
Can you write the shell scripts for these C files (code in C): #include <stdio.h> #include <string.h> #include <ctype.h> int main(int argb, char *argv[]){ char ch; int upper=1; if(argb>1){ if(strcmp(argv[1],"-s")==0){ upper=1; } else if(strcmp(argv[1],"-w")==0){ upper=0; } } while((ch=(char)getchar())!=EOF){ if(upper){ printf("%c",toupper(ch)); } else{ printf("%c",tolower(ch)); } } return 0; } ======================================================== #include <stdio.h> #include <stdlib.h> int calcRange(int array[],int size){ int max=array[1]; int min=array[0]; int a=0; for(a=1;a<size;a++){ if(array[a]>max){ max=array[a]; } } for(a=1;a<size;a++){ if(array[a]<min){ min=array[a]; } } printf("%d-%d=%d\n",max,min,max-min); } int main(int arga, char **argv){...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT