Overview

Introduction

Welcome to the Basics of Scripting Practice Lab. In this module you will be provided with the instructions and devices needed to develop your hands-on skills.

Learning Outcomes

In this module, you will complete the following exercises:

  • Exercise 1 - Working with the Environment Variables
  • Exercise 2 - Working with the Flow Control Constructs
  • Exercise 3 - Working with Scripts

After completing this lab, you will be able to:

  • Read Environment Variables
  • Set Environment Variables
  • Script with decision-making statements
  • Use loop statements in a script
  • Create a Windows Batch File
  • Create a PowerShell Script

Exam Objectives

The following exam objectives is covered in this lab:

  • 4.8: Identify the basics of scripting

Lab Duration

It will take approximately 1 hour to complete this lab.

Exercise 1 - Working with Environment Variables

A variable is mainly used to store data temporarily. This data can be characters, strings, white spaces, alphanumeric characters, special characters and so on. Variables are of two types:

  • Environment variables
  • Shell variables

In this exercise, you will work with the environment variables.

Learning Outcomes

After completing this exercise, you will be able to:

  • Displaying and using environment variables
  • Set environment variables including the permanent ones

Exercise 2 - Working with Flow Control Constructs

Basic scripts can be created to have specific functions. These functions may include workflows or flow control mechanisms. Using if and else statements allows decisions to be made within the bash shell. For example, a script file can be created to automate repetitive tasks or tasks that needs to be executed if specific conditions are met. Furthermore, these flow control mechanisms can be designed to run at specific times. An example of this is to monitor the status of the backup of the server. If the backup has completed successfully then notify the administrator else retry the backup.

Learning Outcomes

After completing this exercise, you will be able to:

  • Script with decision-making statements
  • Use loop statements in a script

Exercise 3 - Working with Scripts

A shell script runs only on a Linux system. For other operating systems, you can create other types of script. For example, you can create a batch file to run in Windows.

For the same operating system, scripts can also be created in various scripting languages or programming software. For example, scripts for Windows can be created in Windows PowerShell, Python, or JavaScript. You can choose the script type according to your requirement.

In this exercise, you will learn to work with script types.

Learning Outcomes

After completing this exercise, you will be able to:

  • Create a Windows batch file
  • Create a PowerShell script

Comprehensive Learning

See the full benefits of our immersive learning experience with interactive courses and guided career paths.