Ch 111 Chapter 11 Advanced Batch Files. Ch 112 Overview This chapter focuses on batch file commands that allow you to:  write sophisticated batch files.

Slides:



Advertisements
Similar presentations
P1PMF Split1 QBASIC. P1PMF Split2QBasic Command Prompt Will launch the emulator DOS operating system? Press Alt + Enter to display the widescreen.
Advertisements

Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
True or false A variable of type char can hold the value 301. ( F )
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Tutorial 10 Programming with JavaScript
Understanding Arrays and Pointers Object-Oriented Programming Using C++ Second Edition 3.
Micro Op SYS (DOS) Chapters 8, 10, 12, 13, DOS Commands DEFRAG SCANDISK MSAV MSBACKUP.
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Chapter 7. 2 Objectives You should be able to describe: The string Class Character Manipulation Methods Exception Handling Input Data Validation Namespaces.
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
CTEC 1863 – Operating Systems Shell Scripting. CTEC F2 Overview How shell works Command line parameters –Shift command Variables –Including.
Ch 101 Introduction to Batch Files. Ch 102 Overview Will learn to create batch files to automate a sequence of commands to accomplish various tasks.
Or CMD/BATCH.  Title this comand makes the cmd prompt’s title whatever you would like it to be.
Programming Batch Files Aim: To introduce the concept of Batch processing and programming techniques. Lesson Outcomes  The need for Batch Processing.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
Agenda Control Flow Statements Purpose test statement if / elif / else Statements for loops while vs. until statements case statement break vs. continue.
Introduction to Shell Script Programming
Ch 21 Command Syntax Using the DIR Command with Parameters and Wildcards.
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
Ch 101 Chapter 10 Introduction to Batch Files. Ch 102 Overview A batch file is a text file that contains an ordered series of commands.
Shell Scripting Introduction. Agenda What is Shell Scripting? Why use Shell Scripting? Writing and Running a Shell Script Basic Commands -ECHO - REM.
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Command Prompt Chapter 10 Introduction to Batch Files Richard Goldman February 7, 2000.
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
Linux Operations and Administration
Flow of Control Part 1: Selection
Objective At the conclusion of this chapter you will be able to:
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Guide to Linux Installation and Administration, 2e1 Chapter 11 Using Advanced Administration Techniques.
Lab Assignment 4 Using Batch Files
Ch 91 Pipes, Filters and Redirection. Ch 92 Overview Will use redirection to redirect standard input and standard output.
MATHEMATICA – AN INTRODUCTION R.C. Verma Physics Department Punjabi University Patiala – PART IV- Programming in Mathematica Input and Output Logical.
Lesson 4-Mastering the Visual Editor. Overview Introducing the visual editor. Working in an existing file with vi. Understanding the visual editor. Navigating.
Chapter Three The UNIX Editors.
Writing Scripts Hadi Otrok COEN 346.
LIN Unix Lecture 5 Unix Shell Scripts. LIN Command Coordination ; && || command1 ; command2 Interpretation: Do command 1. Then do command.
Shell Scripting – Putting it All Together. Agenda Escaping Characters Wildcards Redirecting Output Chaining and Conditional Chaining Unnamed and Named.
Chapter Six Introduction to Shell Script Programming.
All sections to appear here Welcome to my pptPlex Slide Show, this can be executed in either two ways: 1.As a normal PowerPoint slide show: Example hit.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Batch Files Weaker form of UNIX shell scripts. Introduction UNIX may use one of several shells The shell is the command interpreter It interacts with.
Batch Files Weaker form of UNIX shell scripts Copyright © by Curt Hill.
Shell script – part 2 CS 302. Special shell variable $0.. $9  Positional parameters or command line arguments  For example, a script myscript take 2.
A FIRST BOOK OF C++ CHAPTER 14 THE STRING CLASS AND EXCEPTION HANDLING.
Mindstorm NXT-G Introduction Towson University Robotics.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
IST 210: PHP LOGIC IST 210: Organization of Data IST210 1.
Batch Files Flow of Control to Strengthen Copyright © by Curt Hill.
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
Batch Files More flow of control Copyright © by Curt Hill.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Discussion 4 eecs 183 Hannah Westra.
Tutorial 10 Programming with JavaScript
Scripts & Functions Scripts and functions are contained in .m-files
CHAPTER 4 CLIENT SIDE SCRIPTING PART 2 OF 3
Agenda Control Flow Statements Purpose test statement
Tutorial 10 Programming with JavaScript
Presentation transcript:

Ch 111 Chapter 11 Advanced Batch Files

Ch 112 Overview This chapter focuses on batch file commands that allow you to:  write sophisticated batch files  further refine your technique in working with the environment

Ch 113 Batch File Commands Batch files must …  have the file extension.BAT  be an ASCII text file  include legitimate commands

Ch 114 Batch File Commands Any command used at the command line can be used in a batch file.

Ch 115 Batch File Commands Batch files have …  a limited vocabulary ( commands )  a syntax  programming logic

Ch 116 A Review of the REM, PAUSE, and ECHO Commands REM command (remarks)… statements keyed in by user that tell what is the purpose of the batch file.

Ch 117 A Review of the REM, PAUSE, and ECHO Command PAUSE command … instructs the batch file to stop executing until the user takes some action.

Ch 118 A Review of the REM, PAUSE, and the ECHO Command Two ways to interrupt a batch file during execution: Ê Press + C Ë Press +

Ch 119 A Review of the REM, PAUSE, and the ECHO Command ECHO command … displays a command and the output of that command to the screen.

Ch 1110 A Review of the REM, PAUSE, and the ECHO Command When ECHO is ON:  all commands in a batch file are displayed on the screen.

Ch 1111 A Review of the REM, PAUSE, and the ECHO Command When ECHO is OFF …  can see the output of the command, but not the command itself.

Ch 1112 Advanced Features of ECHO and REM To save valuable processing time, use a double colon (::) instead of the REM command.

Ch 1113 Advanced Features of ECHO and REM To delete the display of even the message “ 1 file(s) copied ”, use the device NUL.

Ch 1114 Advanced Features of ECHO and REM Using NUL will not suppress a message such as “file not found”.

Ch 1115 Advanced Features of ECHO and REM To suppress all messages use the command CTTY NUL.

Ch 1116 Advanced Features of ECHO and REM When CTTY NUL is used, must follow with CTTY CON in order to have control of the console.

Ch 1117 Advanced Features of ECHO and REM There is no such thing as a blank line in batch files.

Ch 1118 Advanced Features of ECHO and REM To insert a blank line, key in ECHO followed by a period (ECHO.)

Ch 1119

Ch 1120 The GOTO Command GOTO command …  will branch to a new line, creating a loop  works in conjunction with a label

Ch 1121 The GOTO Command A loop will repeat steps until it is stopped by …  using an IF statement  breaking into the batch file with + C

Ch 1122 The GOTO Command A label …  is preceded by a colon (:)  can be no longer than 8 characters  is not a command

Ch 1123 The GOTO Command GOTO has one parameter …  GOTO label

Ch 1124

Ch 1125 The SHIFT Command The SHIFT command allows for an unlimited number of parameters on the command line.

Ch 1126 The SHIFT Command SHIFT command … changes the position of the replaceable parameter in a batch file.

Ch 1127

Ch 1128 The IF Command IF command … allows for conditional processing.

Ch 1129 The IF Command Conditional processing … compares two items to determine if they are identical, or if one is greater than the other.

Ch 1130 The IF Command The result of comparison testing is either a True or False value.

Ch 1131 The IF Command True = items are identical False = items are not identical

Ch 1132 The IF Command Syntax of IF command: IF

Ch 1133 The IF Command If a condition is True, the command will be executed. If a condition is False, the command will not be executed.

Ch 1134 The IF Command The IF command checks for three conditions.

Ch 1135 IF Command Using Strings To test whether or not one character string is exactly the same as another, use the IF command.

Ch 1136 IF Command Using Strings The strings to be compared are separated by two equal signs (= =).

Ch 1137

Ch 1138 Testing for NULL Values In a batch file it is sometimes possible to be caught in an endless loop.

Ch 1139 Testing for NULL Values A value equal to “nothing” must be placed in a batch file to indicate when to end.

Ch 1140 Testing for NULL Values NULL values … a user-defined value equivalent to nothing (no data).

Ch 1141 Testing for NULL Values Testing for a null value involves using the IF command with quotation marks.

Ch 1142 Testing for NULL Values Use quotation marks to test for null value: IF “%1” = = GOTO LABEL

Ch 1143 Testing for NULL Values “If nothing is there, GOTO somewhere else”

Ch 1144

Ch 1145 The IF EXIST/IF NOT EXIST Command IF EXIST/IF NOT EXIST command: checks for the existence or non-existence of a file.

Ch 1146

Ch 1147 The IF ERRORLEVEL Command Testing Exit code … a code set by a program that indicates a True or False condition when the program finishes executing.

Ch 1148 The IF ERRORLEVEL Command Testing IF ERRORLEVEL command… a statement in a batch file that can test exit codes.

Ch 1149 The IF ERRORLEVEL Command Testing An exit code is tested with ERRORLEVEL to determine if it is greater than or equal to it.

Ch 1150

Ch 1151 Writing Programs to Test for Key Codes Exit codes can be …  set by an operating system program  created by writing a small program

Ch 1152 Writing Programs to Test for Key Codes To write a program a user can …  use a programming language  use an OS utility called DEBUG

Ch 1153 Writing Programs to Test for Key Codes Easiest way to use DEBUG is to create a script file.

Ch 1154 Writing Programs to Test for Key Codes Script file … a set of instructions that can be written in any text editor.

Ch 1155

Ch 1156 The CHOICE Command CHOICE command … prompts the user to make a choice.

Ch 1157 The CHOICE Command Syntax for CHOICE command: CHOICE [/C[:]choices] [/N] [/S] [/T[:]c,nn] [text]

Ch 1158

Ch 1159 The Environment The environment …  is an area that the OS sets aside in memory  holds important info. that the OS needs to know

Ch 1160 The Environment Application programs can …  read any items in the environment  post their own messages there

Ch 1161 The Environment A user can leave a message there through …  the AUTOEXEC.BAT file  other batch files  the command line

Ch 1162 The Environment To leave a message, use the SET command.

Ch 1163 The Environment Syntax for SET command … SET [ variable = [string] ]

Ch 1164

Ch 1165 The DIRCMD Environmental Variable The DIRCMD command variable allows the user to preset, or change the way DIR displays information.

Ch 1166

Ch 1167 The FOR..IN..DO Command The FOR..IN..DO command can be …  issued at the command line  placed in a batch file

Ch 1168 The FOR..IN..DO Command FOR allows the use of a single command to issue several commands at once.

Ch 1169 The FOR..IN..DO Command Syntax for the FOR..IN..DO command at the command line: FOR %variable IN (set) DO command [command-parameters]

Ch 1170 The FOR..IN..DO Command Syntax for the FOR..IN..DO command in a batch program: FOR %variable IN (set) DO command [command-parameters]

Ch 1171

Ch 1172 The CALL Command CALL command … calls (executes) one batch program from another without causing first batch program to stop.

Ch 1173