OPS102 - Week 10- Lab 8-Debaditto Paul

docx

School

Seneca College *

*We aren’t endorsed by this school

Course

102

Subject

Industrial Engineering

Date

Dec 6, 2023

Type

docx

Pages

6

Uploaded by KidElementAardvark40

Report
Lab 8 OPS102 – Week 10 – Batch Shell Scripting in Windows Due: November 17, 2023 11:59 PM Note: The answers to this handout will NOT be posted or emailed to students Student Name: Debaditto Paul Student ID: 126074236 To create a Windows batch file (script), follow these steps: 1. Open a text file, such as a Notepad or WordPad document. 2. Add your commands, starting with @echo [off] , followed by, each in a new line, title [title of your batch script] , echo [first line] , and pause . 3. Save your file with the file extension BAT , for example, test.bat . 4. To run your batch file, double-click the BAT file you just created. 5. To edit your batch file, right-click the BAT file and select Edit
Your raw file will look something like this: Activity 1: Simple Math Script Let's create a simple batch script where we can use of echoing, setting, and arithmetic setting. Perform the following steps: 1. Make certain that you are logged into your Windows by typing cmd.exe from the start button. 2. Add the following lines to the beginning of this file using notepad: @echo of set _var 1=5 set _var2=6 echo var1 is %_var1% echo var2 is %_var2% set /a _result =%_var1%+%_var2% echo result is %_result% pause 3. Use Save AS to save the file in C:\Users\Your userID\BatchScripts and name it simple.bat 4. exit notepad.
5. Issue the following on the command prompt to run the batch script: simple.bat Confirm that your batch script displays the correct answer. Activity 2: CONTROL FLOW STATEMENTS In this activity you will learn how to use control-flow statements to make your batch script behave differently under different situations or conditions . Perform the Following Steps: 1. Make certain that you are logged into your Windows by typing cmd.exe from the start button. 2. Add the following lines to the beginning of this file using notepad: @echo of If “%1” == “” goto :help If “%2” == “” goto :help set /a _result =%1*%2 echo answer is %_result% goto :eof :help echo Usage: mult X Y (Multiply X by Y)
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
3. Use Save AS to save the file in C:\Users\Your userID\BatchScripts and name it mult.bat 4. exit notepad. 5. Issue the following on the command prompt to run the batch script: mult.bat 6. Issue the following on the command prompt to run the batch script: mult.bat 3 5 Confirm that your batch script displays the correct answer.
Rubric: Activity 1: Simple Math Script (25 Marks)
Questions 1-5 5.0 marks Activity 2: CONTROL FLOW STATEMENTS (25 Marks) Questions 2-6 5.0 marks Total: 50 Marks
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