0% found this document useful (0 votes)
22 views

OS Lab 2

This document provides instructions for a lab on command prompt scripting and batch files. It defines batch files and scripting languages. It includes examples of creating batch files to run commands like ipconfig and ping, with and without echoing commands. It also shows writing output to a text file. The document covers arithmetic operators that can be used in batch files and provides an example of an if statement. It asks students to write a batch script that computes the product and difference of two numbers, displays the results on screen with a message, and writes the output to a text file.

Uploaded by

Raj Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

OS Lab 2

This document provides instructions for a lab on command prompt scripting and batch files. It defines batch files and scripting languages. It includes examples of creating batch files to run commands like ipconfig and ping, with and without echoing commands. It also shows writing output to a text file. The document covers arithmetic operators that can be used in batch files and provides an example of an if statement. It asks students to write a batch script that computes the product and difference of two numbers, displays the results on screen with a message, and writes the output to a text file.

Uploaded by

Raj Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Department of Information Technology

Faculty of Engineering and Technology


University of Sindh Jamshoro

LAB # 2
BSIT (Part-III)
SENG- 529 Operating Systems
Command Prompt Scripting and Batch Filing
Student Name________________________________ Role No___________________________

LAB OBJECTIVE: To understand and work with windows command prompt scripting and
batch files

TERMINOLOGIES:

Batch files: a computer file containing a list of instructions to be carried out in turn.

Scripting languages: A scripting or script language is a programming language that supports


scripts: programs written for a special run-time environment that automate
the execution of tasks that could alternatively be executed one-by-one by a
human operator. Scripting languages are often interpreted (rather than
compiled)

PRACTICAL EXERCISES

Create a bat file having following code, execute it and check the output

ipconfig /all
ping google.com
tracert google.com
PAUSE

Create a bat file having following code, execute it and check the output

Echo off
ipconfig /all
ping google.com
tracert google.com
PAUSE

Create a bat file having following code, execute it and check the output written in results.txt
file
ECHO OFF
ipconfig /all >> results.txt
ping google.com >> results.txt
tracert google.com >> results.txt

Arithmetic Operators

Operator Description

+ (Addition) Adds values on either side of the operator.

- (Subtraction) Subtracts right-hand operand from left-hand operand.

* Multiplies values on either side of the operator.


(Multiplication)

/ (Division) Divides left-hand operand by right-hand operand.

Divides left-hand operand by right-hand operand and


% (Modulus)
returns remainder.

Arithmetic operation
echo off
set a= 10
set b= 20
set /a c = %a%+%b%
echo addition is (%c%)

If statement Syntax
If Condition
Statements
Try this code
IF NOT DEFINED _example ECHO Value Missing

FOR YOU
Write batch script which:
o Computes product and difference of two number
o Prints the result on screen with appropriate message
o And writes output in text file.

You might also like