A plus 1002 Sub-objective 4.8

A plus 1002 Sub-objective 4.8 – Identify the basics of scripting.

Welcome to ExamNotes by CertBlaster. This edition will cover Exam Objective 4.8 Identify the basics of scripting. Scripts are a dependable way to execute a series of commands. The beauty of scripts is that they are reusable. Once written or compiled, the script can be run reliably when needed. We will start by defining the file types. Next, we will discuss the contents of the script files and how to format their instructions.

Click here for the A+ Practice Test Bundle for A+ Exams 220-1001 & 220-1002

Script file types

When multiple systems require the same set of commands to be run, script files save time and effort. A script usually contains multiple sets of commands that can be executed manually, at startup, or by a program that uses it. Here are the script file types you’ll need to be aware of along with their specific file types and use.

.bat

A batch file (.bat) is a list of commands that can be run in the Windows environment at the command prompt (serving as the interpreter) or from other scripts. .bat files can be simple text files containing syntactically correct commands which are then saved under the .bat file extension. 

.ps1

When using PowerShell, each script created contains one or more cmdlets and is saved under the .ps1 file extension. As the user types, the created cmdlets are checked dynamically by PowerShell in order to ensure error free execution.

.vbs

VBScript is used to create scripts using a programming language and saves them under the .vbs file extension. VBScript is a simpler version of Visual Basic.

.sh

VBScript also creates .sh script files which are executed in the Linux or UNIX environment.

.py

Python scripts (.py) are created with Python and contain commands to be executed by Python.

.js

JavaScript is used to create .js files, designed to enhance interactivity, which define text that has been designed to work with webpages. The .js script is embedded in the webpage, i.e. an HTML file. The .js file loads when the browser opens a webpage.

Environment variables

Environmental variables are information provided by the operating system that can be used by scripts. This information will include the path and temporary locations for file storage. View the User variables and the System variables by accessing System from Control Panel, selecting System, and then Advanced system settings. Select Environment variables in the Advanced tab of the System Properties box. In this window, properties can be added, edited, or deleted. Note that the variables are assigned separately between the user and the system.

Environment variables

Comment syntax

Some scripts can be quite complex. Remember that once you write a script, other users may need to run it. Add comments in the script such as remarks or instructions regarding the operation of the script. It is important that the command interpreter has a way to disregard these comments so that they are not executed. For example in Windows PowerShell, the # symbol is used to designate a comment line and this text will not be executed.

Basic script constructs

Basic loops

A script containing a basic loop will execute the same command repeatedly. Some scripts run a specified number of times and others run until its conditions are met. A script can also run until the user intervenes with a keystroke combination such as CTRL+C.

Variables

When the name of a data item cannot be exactly specified or is unknown, it is called a variable. In PowerShell the $ represents a variable.

Basic data types

When discussing basic data types, whole numbers are called integers and text entries are referred to as strings.

Click here for the A+ Practice Test Bundle for A+ Exams 220-1001 & 220-1002

That’s all for 4.8! See you in 4.9. You’re almost through.

One to go!!! Good luck on the test!

By continuing to browse this site, you accept the use of cookies and similar technologies that will allow the use of your data by CertBlaster in order to produce audience statistics- see our privacy policy.