“Shell Scripting” with SML

Slides:



Advertisements
Similar presentations
CST8177 bash Scripting Chapters 13 and 14 in Quigley's "UNIX Shells by Example"
Advertisements

UNIX Chapter 12 Redirection and Piping Mr. Mohammad Smirat.
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
EMT 2390L Lecture 4 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
Introduction to UNIX CSE 2031 Fall May 2015.
CS 497C – Introduction to UNIX Lecture 22: - The Shell Chin-Chih Chang
Shell Basics CS465 - Unix. Shell Basics Shells provide: –Command interpretation –Multiple commands on a single line –Expansion of wildcard filenames –Redirection.
Redirection & Pipes Understanding UNIX Input and Output.
Introduction to Unix – CS 21 Lecture 13. Lecture Overview Finding files and programs which whereis find xargs Putting it all together for some complex.
Introduction to Unix – CS 21 Lecture 5. Lecture Overview Lab Review Useful commands that will illustrate today’s lecture Streams of input and output File.
Shell Script Examples.
CTEC 1863 – Operating Systems Shell Scripting. CTEC F2 Overview How shell works Command line parameters –Shift command Variables –Including.
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
Simple Shell Part 1 Due date (75%): April, 2002 Part 2 Due date (25%): Apr 5, 2002.
1 Shell Programming – Extra Slides. 2 Counting the number of lines in a file #!/bin/sh #countLines1 filename=$1#Should check if arguments are given count=0.
BIF703 stdin, stdout, stderr Redirection. stdin, stdout, stderr Recall the Unix philosophy “do one thing well”. Unix has over one thousand commands (utilities)
Advanced UNIX Shell Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
CS 470 Lab 5 Comment your code. Description of Lab5 Create Four projects – Driver – Producer – Filter – Consumer.
Writing C-shell scripts #!/bin/csh # Author: Ken Berman # Date: # Purpose: display command and parameters echo $0 echo $argv[*]
July 17, 2003Serguei A. Mokhov, 1 Shells and Shell Scripts COMP 444/5201 Revision 1.3 January 25, 2005.
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
OPERATING SYSTEMS DESIGN UNIX BASICS & SHELL SCRIPTING.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
Writing Shell Scripts ─ part 3 CSE 2031 Fall October 2015.
Agenda Regular Expressions (Appendix A in Text) –Definition / Purpose –Commands that Use Regular Expressions –Using Regular Expressions –Using the Replacement.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
I/O and Redirection. Standard I/O u Standard Output (stdout) –default place to which programs write u Standard Input (stdin) –default place from which.
Linux file system "On a UNIX system, everything is a file; if something is not a file, it is a process." Sorts of files (on a Linux system) Directories:
Final Exam Review May 3 rd, 2004 Class Meeting 15.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 18 Midterm Review.
1 © 2000 John Urrutia. All rights reserved. Session 5 The Bourne Shell.
CSCI The UNIX System Shell Data Handling: Redirection and Piping
1 Day 18 Bash and the.files. 2 The.files ls shows you the files in your directory –Or at least most of them. –Some files are hidden. Try: ls –a –This.
1 Unix/Linux commands and shell programming-Part 2 (Dr. Mohamed El Bachir Menai)
Haskell Chapter 9. More Input and More Output  Files and Streams  Transforming Input  Not covered  brackets  command-line arguments  bytestrings.
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.
© Prepared By: Razif Razali 1 TMK 265: UNIX SYSTEM CHAPTER FOUR – QUOTING IN DETAIL.
Shell Scripting What is Shell Programming? Putting UNIX commands in a file Seldom used where speed is important Often used to manipulate files To create.
Lesson 6-Using Utilities to Accomplish Complex Tasks.
Familiarizing with UNIX Commands. UNIX Commands Unix systems are heavily command based. This often makes us feel uncomfortable. Moreover the system is.
Various 2. readonly readonly x=4 x=44 #this will give an error (like what in java?)
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
1 Lecture 7 Introduction to Shell Scripts COP 3353 Introduction to UNIX.
1 Lecture 8 Shell Programming – Control Constructs COP 3353 Introduction to UNIX.
Hank Childs, University of Oregon April 15 th, 2016 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / / /
Chapters 13 and 14 in Quigley's "UNIX Shells by Example"
Lecture 7 Introduction to Shell Programming
Lecture 7 Introduction to Shell Scripts COP 3353 Introduction to UNIX.
CSC 352– Unix Programming, Spring 2016
CSC 352– Unix Programming, Spring 2016, Final Exam Guide
Linux file system "On a UNIX system, everything is a file;
The UNIX Shell Learning Objectives:
Shell Scripting March 1st, 2004 Class Meeting 7.
The Linux Operating System
stdin, stdout, stderr Redirection
CSE 303 Concepts and Tools for Software Development
Writing Shell Scripts ─ part 3
CSC 352– Unix Programming, Fall 2012
Sarah Diesburg Operating Systems CS 3430
Programming Assignment 1
Hank Childs, University of Oregon
File redirection ls > out
CS 60 Discussion Review.
John Carelli, Instructor Kutztown University
Simple Shell Due date: March 27, 2002.
More advanced BASH usage
CSC 4630 Meeting 4 January 29, 2007.
Testing grep.c (200 pts) For grep.c, generate 10,000 test cases through the (reverse) DFS search strategy. You are requested to modify grep.c to create.
HW7: Due Dec 5th 23:59 Describe test cases to reach full path coverage of the triangle program by completing the path condition table below. Also, draw.
Presentation transcript:

“Shell Scripting” with SML Kevin Jones Friday, May 13, 2005

Target Functionality Piping between process Branched pipes Echoing output from a a process to a file or standard out along with the next process Basic file handling Simplified environment and argument handling Allow all exceptions without to be caught outside of the structure

Changes in CML Added functionality to Unix structure signature UNIX = sig type proc val executeInEnv : string * string list * string list -> proc val execute : string * string list -> proc val pidOf : proc -> Posix.Process.pid val pipeOf : proc -> Posix.IO.file_desc * Posix.IO.file_desc val streamsOf : proc -> TextIO.instream * TextIO.outstream val mkPipe : string -> TextIO.instream * TextIO.outstream val reapEvt : proc -> Posix.Process.exit_status CML.event val reap : proc -> Posix.Process.exit_status val kill : proc * Posix.Signal.signal -> unit end

SCRIPTML Signature signature SCRIPTML = sig type environment type file datatype pipe = Pipe of (string * string list * environment * bool * (string * bool) option) list * output and output = Branch of pipe list | StdOut | FileAppend of string | FileOverwrite of string val start : string * string list * string list * (string * string list * environment -> unit) -> OS.Process.status val set : environment * (string * string) list -> environment val get : environment -> string -> string option val makeFile : string -> file option val openFile : string -> file option val touchFile : string -> bool val closeFile : file -> unit val readFile : string -> string list val write : file -> string -> unit val pipe : pipe -> unit end;

pipe datatype Complete path to the program Arguments for the program The environment to run it in If it should be echoed to standard out A file the output would be echoed to and if it should overwrite the file if it exists

Argument handling Arguments can be read and put in the environment testProgram -var1=value1 -var2 value2 All of the arguments get passed to the function even if they are added to the environment

Demonstrations

Possible Improvements Some programs seem to not work correctly, notably grep and maybe ls Special cases could be made to handle useful programs that do not work Add support for stream processing functions between processes Thread safety in output to files in pipes