Rexx for Shell Scripting or “We don't need no stinkin' bashes...”

Slides:



Advertisements
Similar presentations
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
Advertisements

Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
CS 497C – Introduction to UNIX Lecture 32: - Shell Programming Chin-Chih Chang
CS 497C – Introduction to UNIX Lecture 22: - The Shell Chin-Chih Chang
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Shell Programming Software Tools. Slide 2 Shells l A shell can be used in one of two ways: n A command interpreter, used interactively n A programming.
Linux+ Guide to Linux Certification, Second Edition
Introduction to Rexx Prof. Chris GauthierDickey COMP 2400: Unix Tools.
23-Jun-15Advanced Programming Spring 2002 bash Henning Schulzrinne Department of Computer Science Columbia University.
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Bash Shell Scripting 10 Second Guide Common environment variables PATH - Sets the search path for any executable command. Similar to the PATH variable.
Shell Script Examples.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Introduction to Shell Script Programming
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.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
An Introduction to Unix Shell Scripting
Linux Shell Programming Tutorial 3 ENGR 3950U / CSCI 3020U Operating Systems Instructor: Dr. Kamran Sartipi.
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
Introduction to Linux OS (IV) AUBG ICoSCIS Team Prof. Volin Karagiozov March, 09 – 10, 2013 SWU, Blagoevgrad.
Linux+ Guide to Linux Certification, Third Edition
Linux Operations and Administration
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Shell Programming. Introducing UNIX Shells  Shell is also a programming language and provides various features like variables, branching, looping and.
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
Shell Programming. Creating Shell Scripts: Some Basic Principles A script name is arbitrary. Choose names that make it easy to quickly identify file function.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Shell Programming Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn the.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
Chapter Six Introduction to Shell Script Programming.
Agenda Positional Parameters / Continued... Command Substitution Bourne Shell / Bash Shell / Korn Shell Mathematical Expressions Bourne Shell / Bash Shell.
Linux+ Guide to Linux Certification, Second Edition
Introduction to Bash Shell. What is Shell? The shell is a command interpreter. It is the layer between the operating system kernel and the user.
Batch Files Flow of Control to Strengthen Copyright © by Curt Hill.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Shell Scripting September 27, 2004 Class Meeting 6, Part II * Notes adapted by Lenwood Heath from previous work by other members of the CS faculty at Virginia.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Linux Administration Working with the BASH Shell.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
COMP075 OS2 Bash Scripting. Scripting? BASH provides access to OS functions, like any OS shell Also like any OS shell, BASH includes the ability to write.
Implementation of a simple shell, xssh
Shell Features CSCI N321 – System and Network Administration
Implementation of a simple shell, xssh (Section 1 version)
Bash Introduction (adapted from chapters 1 and 2 of bash Cookbook by Albing, Vossing, & Newham) CPTE 440 John Beckett.
Agenda Bash Shell Scripting – Part II Logic statements Loop statements
Implementation of a simple shell, xssh
CSC 352– Unix Programming, Fall 2012
Shell Scripting March 1st, 2004 Class Meeting 7.
Variables, Expressions, and IO
CSE 303 Concepts and Tools for Software Development
Intro to PHP & Variables
What is Bash Shell Scripting?
Copyright © – Curt Hill Bash Scripting Fundamentals Copyright © – Curt Hill.
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
Command Substitution Command substitution is the mechanism by which the shell performs a given set of commands and then substitutes their output in the.
Copyright © – Curt Hill Bash Flow of Control Copyright © – Curt Hill.
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Linux Shell Script Programming
Focus of the Course Object-Oriented Software Development
CSC 352– Unix Programming, Fall, 2011
12th Computer Science – Unit 5
Chapter 1: Programming Basics, Python History and Program Components
CST8177 Scripting 2: What?.
Introduction to Bash Programming, part 3
Bash Scripting CS 580U - Fall 2018.
Basic shell scripting CS 2204 Class meeting 7
Presentation transcript:

Rexx for Shell Scripting or “We don't need no stinkin' bashes...” Chip Davis chip@aresti.com 2013 VM Workshop UIPUI

Topics Comparison of Rexx and bash Brief overview of Rexx syntax Delightful features of Rexx A couple of demos Where to get Rexx for Linux

Rexx bash Designed to be easy ANSI standard Independent of OS Runs anywhere Sole designer (+ARB) Human-oriented Few limits Few special characters Single T/F value Easy to read, write, debug Designed to be dense based on sh, ksh, ... Integral to OS Runs on Unix “Growed like Topsy” Machine-oriented Many different limits Many modal special characters Multiple T/F values Not so easy...

validate() { varname=$1 varvalue=$2 if [ ! -z $varvalue ] ; then if [ "${varvalue%${varvalue#?}}" = "/" ] ; then if [ ! -x $varvalue ] ; then echo "** $varname set to $varvalue, but I cannot \ find executable." errors=$(( $errors + 1 )) fi else if in_path $varvalue $PATH ; then find it in PATH." }

validate: parse arg varname varvalue if left(varvalue,1) = '/' then do 'test -x' varvalue if rc then do say "**" varname "set to" varvalue", but I cannot″ , ″find executable." errors = errors + 1 end else if \ in_path(varvalue, path) then do ″find it in PATH." return 0

for directory in $PATH do if [ ! -d $directory ] ; then echo "** PATH contains invalid directory $directory" errors=$(( $errors + 1 )) fi done ---------------------------------------------------------- path = value('PATH',,'SYSTEM') do while path \= ″″ parse var path directory ':' path 'test -d' directory if rc then do say "** PATH contains invalid directory" directory errors = errors + 1 end

Rexx Instructions Null /* comment */ -- another comment Label symbol: Assignment Keyword Command /* comment */ -- another comment [or just a blank line] symbol: Get_Args: exit: symbol = expression foo = length(bar'/'baz) + 2 do say if parse select trace numeric address call interpret expression 'chmod' perms files

Rexx Symbols Allowed Characters: [a - z] [A - Z] [0 - 9] _ . ? ! Format: Must not start with . or [0 - 9] Case-sensitive: No Length Limits: ooRexx: unlimited Regina: 100,000 chars

Rexx Expressions Say ″February has″ 28 + (yr // 4 = 0) ″days″ Any sensible combination of: Constants Variables Operators Functions Blanks may be used between terms for readability Evaluated L-to-R, inner-to-outer parens Result is a character string Say ″February has″ 28 + (yr // 4 = 0) ″days″

Rexx Constants 2.54 -.088 6.02e-23 'Say ″Hi″' '' ″″ ″Don't look″ Stored as character strings Length limited to: 100,000 chars (Regina) ¹ available memory (ooRexx) Numeric 2.54 -.088 6.02e-23 String 'Say ″Hi″' '' ″″ ″Don't look″ Hex 'F8'x 'D0A'X ″c3c8 c9d7″x Binary '111111000'b '11'B ″1111 0011″b

Rexx Variables symbol x15 !0_1? Last_Matching_Value_Found Length of value limited only by available memory Initial value is symbol in uppercase Simple: No '.'s in symbol x15 !0_1? Last_Matching_Value_Found Compound: Periods separate stem and tails in symbol matrix.12.4 tax.item.st A4.? Values of tail variables are substituted and derived name is used to access the value matrix.12.4 tax.book.NC A4.Why not? stem. = expr sets all stem.tail.tail... to value of expr matrix. = 0 line. = '' set.=″none″

Rexx Operators Prefix (monadic) + - \ Power ** Multiplicative * / % // Additive + - Concatenation || [abbutal] [blank] Comparison = < > <= >= tComparison == << >> <<= >== AND & OR/XOR | && An expression may contain any combination of operators

Rexx Functions symbol( [expr [, expr] ... ] ) Built-in ANSI Functions Platform Extensions External Function Packages SubStr(fn, LastPos('/', fn) + 1) Your Own Subprocedure that returns a value Returned value replaces invocation Internal vs. External to executing program MyFunc(ifn, ofn, recno, '*')

Trace Displays interpreted line before execution Many levels of detail: ACEFILNOR (may be set dynamically) Keyword instruction in code or interpreter invocation option Interactive tracing Pauses for input after tracing instruction Anything entered will be executed as if it were at that line in the program Allows significant debugging at the point of failure Last instruction traced may be re-executed Trace setting saved across subprocedure boundaries May skip over uninteresting instructions

Trace Identifiers *-* Rexx instruction as found in program Trace output line format: line# trace_id trace_data *-* Rexx instruction as found in program >>> String result of executing instruction >.> String ignored in Parse template >C> Derived name of compound variable >F> String returned from a Function >L> Literal string encountered >O> Result of a dyadic operation >P> Result of a monadic (prefix) operation >V> String retrieved from a variable +++ Trace message

Address Controls to which environment a command is sent Redirects STDIO for one command or permanently ADDRESS [ environment [ command ] [ WITH redirects ] ] ADDRESS [ environment [ WITH redirects ] ] environment: [SYSTEM | COMMAND | REXX] command: [external command] redirects: [INPUT inp_redir] [OUTPUT out_redir] [ERROR err_redir] inp_redir: [NORMAL] | where out_redir: [NORMAL] | [REPLACE | APPEND] where err_redir: [NORMAL] | [REPLACE | APPEND] where where: [STREAM | STEM | LIFO | FIFO] name Address System 'grep ^chip:' With Input Stream 'etc_pw' , Output Stem users.

Demos validator bashit mychmod

Installing Rexx Regina Rexx Open Object Rexx Rexx Language Association sourceforge.net/projects/regina-rexx/files/regina-rexx/ Open Object Rexx sourceforge.net/projects/oorexx/files/oorexx/ Rexx Language Association www.rexxla.org

Finally... Questions? Comments? Brickbats?