CPSC1280_Lab7

docx

School

Langara College *

*We aren’t endorsed by this school

Course

1280

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

4

Report

Uploaded by KidGrousePerson67

CPSC 1280 – Lab 7 awk must be used Pre-lab activity a. Login to AWS Cloud9 b. Create a folder, Lab7-yourstudentID Store all your data and work in this folder c. Work independently Lab Filename: Lab7_1_yourstudentID.sh #!/bin/bash read -p "Which server should be pinged: " server_addr # -c 1 sends 1 echo request # -4 means IPv4 , -6 IPv6 or ping6 # 2 (standard error) > err (any file) # || only executes the second if the previous fails ping -4 -c 2 $server_addr 2>err || echo "Server Dead" Actions: 1. Save the file 2. Execute chmod +x to make the script executable (provide screenshot) [1 mark] 3. Run the script (provide screenshot) [1 mark] 1
CPSC 1280 – Lab 7 4. Observe and explain [2 marks] a. What happens if you enter a valid IP address or server name? i. Which server should be pinged: google.com The server run normally. It’s show ping and server_addr. b. What happens if you enter an invalid IP address or server? i. Which server should be pinged: abc The server is dead and print an error in err. c. What does err contains and when does it get created? Ping and server_addr. It will create when the server dead. 2
CPSC 1280 – Lab 7 Filename: Lab7_2_yourstudentID.sh [3 marks – no partial points] #!/bin/bash read -p "Enter the username: " username sudo useradd $username # fix this code to show the home directory of the user echo -n "The home directory: " && ls -l # -e to be able to execute \n echo -e "\n Change the password" sudo passwd $username echo -e "\n Test your new user account" sudo su ${username} # sudo userdel -r username (to delete the account) Sample output Actions: 1. Fix the code given to display the home directory of the new user. You can use ls , grep/awk 2. Save the script. 3. Make it executable 4. Run the script 3
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
CPSC 1280 – Lab 7 Filename: Lab7_3_yourstudentID.sh Ifconfig eth0 will give the following information (see below) Write a script to extract and display the following information [3 marks] 1 mark each What to submit 1. Right click on Lab7-yourstudentID folder, then select “Download”. This would download all the files in your folder and create a zip file on your machine 2. Upload the Lab7-yourstudentID.zip to D2L Failure to follow instructions will get 2 marks deduction. 4