Script-Lab1

.docx

School

Seneca College *

*We aren’t endorsed by this school

Course

102

Subject

Computer Science

Date

Jun 2, 2024

Type

docx

Pages

11

Uploaded by CommodoreTank14566

Report
OPS102: Introduction to Shell Scripting Lab Include screenshots of your outputs and upload Task 1 Create a Bash Shell script to clear the screen and then display all users that are currently logged onto the system. We created a text file named week7lab in nano editor, we initialized the file with a “shebang” :- “#” and “!” to make it a bash shell script . Then we added the clear and who command to clear the output screen and display all the users currently logged onto the system. We gave the user execute permission for the file week7lab as it is necessary.
Task 2: Write a Bash shell script to display the following message using an environment variable so it will work in any user’s terminal if the shell script was issued: My username is: (your-username) We edited the text file week7lab by adding an echo command and an environmental variable $USER which displays the username of the user. This would work on anyone’s terminal as it has no hard code and takes different input for different users.
Task 3: Write a Bash shell script to prompt the user for their full name and prompt the user for their age to be stored in user-defined variables. Display the following output using the values of those variables: Enter your Full Name: (your full name) Enter your Age: (your age) Hello, my name is (your full name), and I am (your age) years old. We used the read command to take input from the user through the prompt and store that in the user defined variables name and age, then we used the echo command to display the information by calling the variables by using the $ sign.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help