Introduction to Rexx Prof. Chris GauthierDickey COMP 2400: Unix Tools.

Slides:



Advertisements
Similar presentations
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
Advertisements

Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 Changing Control.
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
Bash, part 2 Prof. Chris GauthierDickey COMP Unix Tools.
Information Technology Center Hany Abdelwahab Computer Specialist.
REXX - part 2 Prof. Chris GauthierDickey COMP Unix Tools.
Guide To UNIX Using Linux Third Edition
Bash Shell Scripting 10 Second Guide Common environment variables PATH - Sets the search path for any executable command. Similar to the PATH variable.
UNIT II Decision Making And Branching Decision Making And Looping
Shell Scripting Awk (part1) Awk Programming Language standard unix language that is geared for text processing and creating formatted reports but it.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)PHP Recap.
4. Python - Basic Operators
Agenda Control Flow Statements Purpose test statement if / elif / else Statements for loops while vs. until statements case statement break vs. continue.
1 Operating Systems Lecture 3 Shell Scripts. 2 Shell Programming 1.Shell scripts must be marked as executable: chmod a+x myScript 2. Use # to start a.
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
Introduction to Python Basics of the Language. Install Python Find the most recent distribution for your computer at:
Nael Alian Introduction to PHP
Python Control Flow statements There are three control flow statements in Python - if, for and while.
CIS 218 Advanced UNIX1 CIS 218 – Advanced UNIX (g)awk.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
COMP 116: Introduction to Scientific Programming Lecture 28: Midterm #2 Review.
CPS120 Introduction to Computer Science Iteration (Looping)
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
Linux Operations and Administration
Shell Scripting AFNOG IX Rabat, Morocco May 2008.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
PHP Logic. Review: Variables Variables: a symbol or name that stands for a value – Data types ( Similar to C++ or Java): Int, Float, Boolean, String,
CPS120: Introduction to Computer Science Decision Making in Programs.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
Introduction to Java Java Translation Program Structure
CMP-MX21: Lecture 5 Repetitions Steve Hordley. Overview 1. Repetition using the do-while construct 2. Repetition using the while construct 3. Repetition.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Writing Scripts Hadi Otrok COEN 346.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
Repetition. Loops Allows the same set of instructions to be used over and over again Starts with the keyword loop and ends with end loop. This will create.
CPS120 Introduction to Computer Science Iteration (Looping)
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
© 2006 Lawrenceville Press Slide 1 Chapter 6 The Post-Test Do…Loop Statement  Loop structure that executes a set of statements as long as a condition.
Rexx Programming1 REXX Programming. Rexx Programming2 INTRODUCTION What is REXX ?  REstructured eXtended eXecuter  Simple Programming Language  Can.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
Learning Javascript From Mr Saem
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
© 2010 Lawrenceville Press Slide 1 Chapter 5 The Do…Loop Statement  Loop structure that executes a set of statements as long as a condition is true. 
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Rexx for Shell Scripting or “We don't need no stinkin' bashes...”
Department of Computer Engineering
Chapter 6: Loops.
Agenda Bash Shell Scripting – Part II Logic statements Loop statements
Operators Operators are symbols such as + (addition), - (subtraction), and * (multiplication). Operators do something with values. $foo = 25; $foo – 15;
JavaScript Syntax and Semantics
PHP Introduction.
Expressions and Control Flow in JavaScript
JavaScript: Control Statements.
Agenda Control Flow Statements Purpose test statement
Conditions and Ifs BIS1523 – Lecture 8.
An Introduction to Java – Part I, language basics
T. Jumana Abu Shmais – AOU - Riyadh
Selection Statements.
Computer Science Core Concepts
COMPUTING.
Review The Unix Shells Graham Glass and King Ables,
Presentation transcript:

Introduction to Rexx Prof. Chris GauthierDickey COMP 2400: Unix Tools

2 What is Rexx? Rexx is a programming language used primarily on the IBM mainframes, but also available on other platforms e.g., regina on the Linux, OS X, and Windows platform It’s a scripting language, to be fair, much like bash in functionality, but different syntactically

3 Rexx Rexx is vital for z/VM as you can use it to build and glue CMS applications together Rexx is composed of: operators, symbols, etc A tiny core of instructions: only 20 or so 70 built-in functions the ability to execute external commands

4 Rexx on Linux Unlike bash, you don’t have a Rexx shell on Linux Instead, you have regina, a Rexx interpreter You have to write your code and execute it using regina Like all other scripts, you can begin your Rexx script with the #! to indicate the interpreter

5 Rexx on Linux Your first Rexx program Note the #!/usr/bin/regina which specifies the interpreter /* */ denotes a comment say is a command like echo in bash #!/usr/bin/regina /* this is a rexx comment */ say “Hello World!”

6 Rexx Composition Rexx is made up of: Instructions, which are keywords, assignments, labels, and commands Built-in functions System supplied functions

7 Variables A Rexx variable can consist of [A-Za-z#$_]([A-Za-z0-9#$_...])* <-- yes, a regex! RC, SIGL, RESULT are keywords you can’t use You can’t begin with a. or chars is the max variable length

8 Assignments We use = for assignment x = 5 #9F3D = ‘hello’ y = m * x + b a = b

9 Math Operators: +, -, *, /: the usual %: DIVIDE and drop the remainder //: DIVIDE and only return the remainder **: Exponentiate #!/usr/bin/regina say say 10 % 3 say 10 // 3 say 10 ** 3

10 Concatenation Putting a blank between values places a single blank between them in output Putting || places no blanks between the items #!/usr/bin/regina w1=’H’ w2=’AL’ w3=’is back’ /* note the multiple spaces, but it outputs only one space */ SAY w1||w2 w3

11 Comparison == is strictly equal = is equal \== is not strictly equal \= is not equal > greater than < less than >< greater than or less than

12 Boolean Operators & returns 1 if they are both true, 0 otherwise | returns 1 if at least one is true, 0 otherwise && returns 1 if only one comparison (but not both) is true, 0 otherwise prefix \ returns the opposite response \(5 = 4)

13 IF-THEN-ELSE The if-then-else clause is just like you expect it to work It’s good programming practice to use a NOP command at an ELSE that doesn’t have a body Your if-expression must result in 1 or 0 #!/usr/bin/regina PARSE ARG v1 v2 if v1 = ‘hello’ then say ‘Goodbye’ if v2 = ‘world’ then do say ‘universe!’ end else do say ‘huh?’ end

14 SELECT Select is slightly different than most languages #!/usr/bin/regina SELECT WHEN v1 = 1 THEN say ‘Got 1’ WHEN v1 = 2 THEN say ‘Got 2’ WHEN v1 = 3 THEN say ‘Got 3’ OTHERWISE say ‘Many’ END

15 The DO loop The DO loop is like a for loop We can also loop ‘forever’ #!/usr/bin/regina parse arg x DO i = 1 to x by 1 say i END do FOREVER say ‘Oh no!’ end

16 We can exit a loop with LEAVE, EXIT, or ITERATE LEAVE terminates the loop and continues running EXIT exits the script ITERATE jumps back to the top of the loop, including reading the condition Exiting loops

17 WHILE and UNTIL DO WHILE expression lets us test an expression, which if true will continue to execute the loop DO UNTIL expression lets us test an expression, which if false, will continue to execute the loop UNTIL will NOT test until the END of the loop