Scripting OS X. Armin Briegel. Mac Admin, Consultant and Author
|
|
- Colleen Welch
- 5 years ago
- Views:
Transcription
1 Scripting OS X Armin Briegel Mac Admin, Consultant and Author
2 Scripting OS X Armin Briegel Mac Admin, Consultant and Author
3 Scripting Bash Armin Briegel Mac Admin, Consultant and Author
4 Scripting Bash #! is not a curse word
5 Scripting Bash #! is just the beginning
6 #!*$%
7
8 scriptingosx.com/bash
9 bash
10 bash "bourne again shell",1989, GNU bsh "Bourne shell", 1979, UNIX v7 sh "Thompson shell", 1971
11 bash sh bsh bash bash3 bash4 v now
12 macos shells Built-in: sh bash (3.2) Optional fish bash (4.x) csh ksh tcsh zsh
13 bash
14 shell
15 Interactive Shell Interactive command line process control files and pipes UserShell: /bin/bash
16 Interactive Shell
17 Interactive Shell
18 shell
19 Shell Scripting interpret script files sequential commands control structures comments #!/bin/bash
20 shell UserShell: /bin/bash #!/bin/bash
21 shell UserShell: /bin/zsh #!/bin/bash
22 shell rshell: /usr/local/bin/fish #!/bin/bash
23 bash UserShell: /bin/bash #!/bin/bash
24 Scripting bash
25
26 Why?
27 Why? Automation Simplification Error prevention/avoidance Codifying Processes Documentation Share
28
29
30 where?
31 Everywhere!
32 Where? File and Metadata Management Installation scripts (pre-/postinstall) Configuration login scripts (settings/defaults/profiles) machine setup (networksetup/systemsetup) User Management creation/cleanup/deletion/promotion
33 Where? Data Gathering/Asset Management Jamf Extension Attributes Munki Report osquery Zentral
34 When? Events Triggers scheduled launchd login outset startup manually file events
35 an example
36 ssh "mkdir -p /tmp/pkgs" scp App.pkg ssh -t "sudo installer /tmp/pkgs/app.pkg -tgt /"
37 ssh "mkdir -p /tmp/pkgs" scp App.pkg ssh -t "sudo installer /tmp/pkgs/app.pkg -tgt /"
38 path="/tmp/pkgs" pkg="app.pkg" ssh "mkdir -p /tmp/pkgs" scp App.pkg ssh -t "sudo installer /tmp/pkgs/app.pkg -tgt /"
39 path="/tmp/pkgs" pkg="app.pkg" ssh $host "mkdir -p $path" scp $pkg $host:$path/$pkg ssh -t $host "sudo installer $path/$pkg -tgt /"
40 another example
41 Scripting bash pkgbuild --root payload --identifier pkg.policybanner --version installlocation /Library/Security PolicyBanner.pkg buildpolicybannerpkg.sh
42 Scripting bash pkgbuild --root payload --identifier pkg.policybanner --version install-location /Library/Security PolicyBanner.pkg
43 Scripting bash $ chmod +x buildpolicybanner.sh $./buildpolicybanner.sh pkgbuild: Inferring bundle components from contents of payload pkgbuild: Wrote package to PolicyBanner.pkg
44 Scripting bash pkgbuild --root payload --identifier pkg.policybanner --version install-location /Library/Security PolicyBanner.pkg
45 clean script continue on next line pkgbuild --root payload \ --identifier pkg.policybanner \ --version 1.0 \ --install-location "/Library/Security" \ PolicyBanner.pkg
46 Shebang #!/bin/bash pkgbuild --root payload \ --identifier pkg.policybanner \ --version 1.0 \ --install-location "/Library/Security" \ PolicyBanner.pkg
47 #! shebang sha-bang hashbang pound-bang hash-pling
48 #! who interprets the script file #!/bin/bash #!/bin/sh
49 sh vs bash minimum common shell better
50 sh is bash $ sh --version GNU bash, version (1)
51 sh is bash If bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming to the POSIX standard as well. (bash man page)
52 sh bsh bash bash now
53
54
55
56
57 sh is bash #!/bin/sh #!/bin/bash
58 Assumptions #!/bin/bash pkgbuild --root payload \ --identifier pkg.policybanner \ assumes PATH --version 1.0 \ --install-location "/Library/Security" \ PolicyBanner.pkg
59
60 Assumptions #!/bin/bash pkgbuild --root payload \ --identifier pkg.policybanner \ --version 1.0 \ --install-location "/Library/Security" \ PolicyBanner.pkg
61 Assumptions #!/bin/bash /usr/bin/pkgbuild --root payload \ --identifier pkg.policybanner \ --version 1.0 \ --install-location "/Library/Security" \ PolicyBanner.pkg
62 Variables #!/bin/bash export PATH=/usr/bin:/bin:/usr/sbin:/sbin pkgbuild --root payload \ --identifier pkg.policybanner \ --version 1.0 \ --install-location "/Library/Security" \ PolicyBanner.pkg current working directory
63 Variables #!/bin/bash export PATH=/usr/bin:/bin:/usr/sbin:/sbin projectfolder=$(dirname "$0") pkgbuild --root payload \ --identifier pkg.policybanner \ --version 1.0 \ --install-location "/Library/Security" \ PolicyBanner.pkg
64 Assigning Variables "zeroth" argument is path to script projectfolder=$(dirname "$0")
65 Assigning Variables returns enclosing directory projectfolder=$(dirname "$0")
66 Assigning Variables projectfolder=`dirname "$0"`
67 Assigning Variables no spaces! projectfolder=$(dirname "$0")
68 Substituting Variables always quote variable substitutions pkgbuild --root "$projectfolder/payload" \
69 Variables #!/bin/bash export PATH=/usr/bin:/bin:/usr/sbin:/sbin projectfolder=$(dirname "$0") pkgbuild --root payload \ --identifier pkg.policybanner \ --version 1.0 \ --install-location "/Library/Security" \ PolicyBanner.pkg
70 Variables #!/bin/bash export PATH=/usr/bin:/bin:/usr/sbin:/sbin projectfolder=$(dirname "$0") pkgbuild --root "${projectfolder}/payload" \ --identifier pkg.policybanner \ --version 1.0 \ --install-location "/Library/Security" \ PolicyBanner.pkg
71 Variables #!/bin/bash export PATH=/usr/bin:/bin:/usr/sbin:/sbin projectfolder=$(dirname "$0") pkgbuild --root "${projectfolder}/payload" \ --identifier pkg.policybanner \ --version 1.0 \ --install-location "/Library/Security" \ "${projectfolder}/policybanner.pkg"
72 Variables #!/bin/bash export PATH=/usr/bin:/bin:/usr/sbin:/sbin pkgname="policybanner" version="1.0" projectfolder=$(dirname "$0") pkgbuild --root "${projectfolder}/payload" \ --identifier pkg.policybanner \ --version 1.0 \ --install-location "/Library/Security" \ "${projectfolder}/policybanner.pkg"
73 Variables #!/bin/bash export PATH=/usr/bin:/bin:/usr/sbin:/sbin pkgname="policybanner" version="1.0" identifier="com.scriptingosx.${pkgname}" projectfolder=$(dirname "$0") pkgbuild --root "${projectfolder}/payload" \ --identifier pkg.policybanner \ --version "${version}" \ --install-location "/Library/Security" \ "${projectfolder}/policybanner.pkg"
74 Variables #!/bin/bash export PATH=/usr/bin:/bin:/usr/sbin:/sbin pkgname="policybanner" version="1.0" identifier="com.scriptingosx.${pkgname}" projectfolder=$(dirname "$0") pkgbuild --root "${projectfolder}/payload" \ --identifier "${identifier}" \ --version "${version}" \ --install-location "/Library/Security" \ "${projectfolder}/${pkgname}-${version}.pkg"
75 Conditionals if [[ -e "${pkgpath}" ]]; then read -p "Package already exists! Overwrite? (y/n) " answer if [[! ${answer} == "y" ]]; then exit 1 fi fi
76 [[ ]] or [ ]
77 [ ] POSIX or sh compatible actually [ is a synonym for test weird syntax issues
78 [[ ]] only bash more resilient for empty variables and && and or boolean operators string comparison with wildcards regular expression comparison with =~
79 Conditionals if [[ -e "${pkgpath}" ]]; then read -p "Package already exists! Overwrite? (y/n) " answer if [[! ${answer} == "y" ]]; then exit 1 fi fi
80 "Simple" Script #!/bin/bash export PATH=/usr/bin:/bin:/usr/sbin:/sbin pkgname="policybanner" version="1.0" identifier="com.scriptingosx.${pkgname}" projectfolder=$(dirname "$0") pkgpath="${projectfolder}/${pkgname}-${version}.pkg" if [[ -e "${pkgpath}" ]]; then read -p "Package already exists! Overwrite? (y/n) " answer if [[! ${answer} == "y" ]]; then exit 1 fi fi pkgbuild --root "${projectfolder}/payload" \ --identifier "${identifier}" \ --version "${version}" \ --install-location "/Library/Security" \ "${pkgpath}"
81 Version Control
82 Version Control every script commit often and regularly repo is history and library share
83
84
85 Quoting
86 Quoting buildfolder=~/"my Great Project/" rm -Rf $buildfolder/*
87 Quoting buildfolder=~/"my Great Project/" rm -Rf ~/My Great Project/*
88 Quoting buildfolder=~/"my Great Project/" rm -Rf ~/My rm -Rf Great rm -Rf Project/*
89 Quoting buildfolder=~/"my Great Project/" rm -Rf $buildfolder/*
90 Quoting buildfolder=~/"my Great Project/" rm -Rf "$buildfolder"/*
91 Quoting buildfolder=~/"my Great Project/" rm -Rf "$buildfolder/*"
92 Quoting buildfolder=~/"my Great Project/" rm -Rf "$buildfolder"/*
93 Quoting buildfolder="$1" first argument rm -Rf "$buildfolder"/* $./myscript.sh "My Great Folder"
94 Quoting buildfolder="" rm -Rf ""/*
95 Quoting buildfolder="" rm -Rf /* rm: /Applications/DVD Player.app/ Contents/_CodeSignature/ CodeResources: Operation not permitted Thank you, SIP!
96 Defensive Code buildfolder="$1" rm -Rf "$buildfolder"/*
97 Defensive Code if [[ -n $1 ]]; then buildfolder="$1" rm -Rf "$buildfolder"/* else echo 'No argument' exit 1 fi
98 Defensive Code buildfolder=${1:?"no argument"} when this is unset log this and fail
99 Defensive Code buildfolder=${1:-"build"} when this is unset use this value
100 Defensive Code ${var:-"build"} default value ${var:?"no value!"} error and exit
101 Defensive Code ${var:-"build"} default value ${var:="build"} assign default ${var:?"no value!"} error and exit ${var:+"build"} overwrite
102 Defensive Code ${var:-"build"} default value ${var:?"no value!"} error and exit
103 Defensive Code buildfolder="$1" rm -Rf "$buildfolder"/*
104 Defensive Code buildfolder="${1:?'no argument'}" rm -Rf "$buildfolder"/*
105 Defensive Code if [[ -n $1 ]]; then buildfolder="$1" rm -Rf "$buildfolder"/* else echo 'No argument' exit 1 fi
106 ShellCheck
107 d Shellcheck
108 ShellCheck Line 14: read -p "Package already exists! Overwrite? (y/n) " answer ^-- SC2162: read without -r will mangle backslashes. Line 24: ${pkgpath} ^-- SC2086: Double quote to prevent globbing and word splitting.
109 Strict Mode set -euo pipefail
110 Strict Mode set -e fail on non-zero command set -u fail on unset variables set -o pipefail any element of a pipe chain fails
111 Trace Mode set -x Trace Mode
112 Trace Mode $ bash -x buildpolicybannerpkg.sh + export PATH=/usr/bin:/bin:/usr/sbin:/sbin + PATH=/usr/bin:/bin:/usr/sbin:/sbin + pkgname=policybanner + version=1.0 + identifier=com.scriptingosx.policybanner ++ dirname buildpolicybannerpkg.sh + projectfolder=. + pkgpath=./policybanner-1.0.pkg + [[ -e./policybanner-1.0.pkg ]] + read -p 'Package already exists! Overwrite? (y/n) ' answer Package already exists! Overwrite? (y/n) y + [[! y == \y ]] + pkgbuild --root./payload --identifier com.scriptingosx.policybanner --version install-location /Library/Security./ PolicyBanner-1.0.pkg pkgbuild: Inferring bundle components from contents of./payload pkgbuild: Wrote package to./policybanner-1.0.pkg
113 Trace Mode set -x bash -x script.sh
114 Trace Mode set -x... set +x
115 bash vs everything else
116 bash Pros everywhere process control, file management tools awk, sed, grep, networksetup, systemsetup, scutil, pmset, dscl, sysadminctl, etc.
117 bash Pros documentation examples resources community
118 bash Cons data types: dict, array (bash4) complex data files: plist, xml, json User Interaction
119 AppleScript Swift
120 AppleScript Pros inter application data communication (where supported) FileMaker, Adobe, MS Office, etc. Simple UI: dialogs, alerts, notifications
121 AppleScript Cons usually requires user logged in troublesome when running as root Future?
122
123 bash + AppleScript $ osascript -e 'display alert "Hey!"'
124 bash + AppleScript $ osascript -e 'display notification "Hey!"'
125 bash + AppleScript Use Bash "Here Files" to include longer AppleScripts # prints the path of the front Finder window open function pwdf () { osascript <<EndOfScript tell application "Finder" if (count of Finder windows) is 0 then set dir to (desktop as alias) else set dir to ((target of Finder window 1) as alias) end if return POSIX path of dir end tell EndOfScript
126 bash + AppleScript Use osascript shebang #!/usr/bin/osascript on run arguments tell application "Finder" -- no argument: get frontmost window or desktop if (count of arguments) is 0 then if (count of windows) is 0 then set dir to (desktop as alias) else set dir to ((target of Finder window 1) as alias) end if else if first item of arguments is in {"-all", "-a"} then
127 bash + AppleScript Use osascript shebang to write #!/usr/bin/osascript on run arguments tell application "Finder" -- no argument: get frontmost window or desktop if (count of arguments) is 0 then if (count of windows) is 0 then set dir to (desktop as alias) else set dir to ((target of Finder window 1) as alias) end if else if first item of arguments is in {"-all", "-a"} then
128 AppleScript + bash
129 AppleScript Swift
130 Python Pros comparatively easy learning curve complex data objects: dict, list complex files: xml, plist, json cross-platform
131 Python Bridge Cocoa/Objective-C Bridge from Foundation import CFPreferencesCopyAppValue print CFPreferencesCopyAppValue("idleTime", "com.apple.screensaver")
132
133 Python Cons access to Cocoa libraries steep learning curve bridge can be finicky
134 AppleScript Swift
135 Swift Pros "native" language to macos interpreted, Playgrounds and compiled complex data types, control structures xml, plist and json (Swift 4) native Apps (Mac and ios)
136 Swift Pros #!/usr/bin/swift -swift-version 3 import Foundation let samplepath = "../examples" let dictpath = "\(samplepath)/berry.plist" if let sampledict = NSDictionary(contentsOfFile: dictpath) { for (key, value) in sampledict { print("\(key) = \(value)") } } else { print("couldn't read: \(dictpath)") }
137 Swift Cons complex object-oriented language moving target (Swift 1, 2, 3, 3.1, 3.2, 4)
138 (not a complete list) AppleScript Swift
139 Scripting bash
140 Scripting bash Automate (even simple things) Embrace bash Quote Write Defensive Code Use Version Control
141 Further Learning tldp.org/ldp/abs/html
142 scriptingosx.com/bash
143 Scripting OS X Armin Briegel Mac Admin, Consultant and Author scriptingosx
Basic Brilliant Scripting for Beginners. Bryce Carlson
Basic Brilliant Scripting for Beginners Bryce Carlson Basic Bash for Beginners Basic Brilliant Scripting for Beginners Bryce Carlson bash script for macos Bryce Carlson Senior Support Engineer at Jamf
More informationardpower Documentation
ardpower Documentation Release v1.2.0 Anirban Roy Das May 18, 2016 Contents 1 Introduction 1 2 Screenshot 3 3 Documentaion 5 3.1 Overview................................................. 5 3.2 Installation................................................
More informationBash, In A NutShell RUSTY MYERS - SYSTEMS ADMINISTRATOR, PENN STATE CHRIS LAWSON - IT CONSULTANT/SUPPORT SPECIALIST, PENN STATE ALTOONA
Bash, In A NutShell RUSTY MYERS - SYSTEMS ADMINISTRATOR, PENN STATE CHRIS LAWSON - IT CONSULTANT/SUPPORT SPECIALIST, PENN STATE ALTOONA BASH, IN A NUTSHELL What is bash? Brian Fox 1989 Bourne Again Shell
More informationTools and Process for Streamlining Mac Deployment. Tim Sutton Concordia University, Faculty of Fine Arts Montreal
Tools and Process for Streamlining Mac Deployment Tim Sutton Concordia University, Faculty of Fine Arts Montreal Things change Release cycle Annual releases of macos, ios Mid-cycle features added in
More informationLecture 8. Introduction to Shell Programming. COP 3353 Introduction to UNIX
Lecture 8 Introduction to Shell Programming COP 3353 Introduction to UNIX 1 What is a shell script? An executable file containing Unix shell commands Programming control constructs (if, then, while, until,
More information9.2 Linux Essentials Exam Objectives
9.2 Linux Essentials Exam Objectives This chapter will cover the topics for the following Linux Essentials exam objectives: Topic 3: The Power of the Command Line (weight: 10) 3.3: Turning Commands into
More informationCSCI 211 UNIX Lab. Shell Programming. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science
CSCI 211 UNIX Lab Shell Programming Dr. Jiang Li Why Shell Scripting Saves a lot of typing A shell script can run many commands at once A shell script can repeatedly run commands Help avoid mistakes Once
More informationMore Raspian. An editor Configuration files Shell scripts Shell variables System admin
More Raspian An editor Configuration files Shell scripts Shell variables System admin Nano, a simple editor Nano does not require the mouse. You must use your keyboard to move around the file and make
More informationIntroduction to Shell Scripting
Introduction to Shell Scripting Evan Bollig and Geoffrey Womeldorff Presenter Yusong Liu Before we begin... Everyone please visit this page for example scripts and grab a crib sheet from the front http://www.scs.fsu.edu/~bollig/techseries
More informationUNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo
UNIX COMMANDS AND SHELLS UNIX Programming 2015 Fall by Euiseong Seo What is a Shell? A system program that allows a user to execute Shell functions (internal commands) Other programs (external commands)
More informationTearing open packages
Tearing open packages What is a package? A package is an archive of files and directories. The archive contains information about location, kind, owner, group, and mode of each file and directory. The
More informationAssignment clarifications
Assignment clarifications How many errors to print? at most 1 per token. Interpretation of white space in { } treat as a valid extension, involving white space characters. Assignment FAQs have been updated.
More informationLecture 5. Essential skills for bioinformatics: Unix/Linux
Lecture 5 Essential skills for bioinformatics: Unix/Linux UNIX DATA TOOLS Text processing with awk We have illustrated two ways awk can come in handy: Filtering data using rules that can combine regular
More information5/20/2007. Touring Essential Programs
Touring Essential Programs Employing fundamental utilities. Managing input and output. Using special characters in the command-line. Managing user environment. Surveying elements of a functioning system.
More informationVi & Shell Scripting
Vi & Shell Scripting Comp-206 : Introduction to Week 3 Joseph Vybihal Computer Science McGill University Announcements Sina Meraji's office hours Trottier 3rd floor open area Tuesday 1:30 2:30 PM Thursday
More informationEssentials for Scientific Computing: Bash Shell Scripting Day 3
Essentials for Scientific Computing: Bash Shell Scripting Day 3 Ershaad Ahamed TUE-CMS, JNCASR May 2012 1 Introduction In the previous sessions, you have been using basic commands in the shell. The bash
More informationIntroduction Variables Helper commands Control Flow Constructs Basic Plumbing. Bash Scripting. Alessandro Barenghi
Bash Scripting Alessandro Barenghi Dipartimento di Elettronica, Informazione e Bioingegneria Politecnico di Milano alessandro.barenghi - at - polimi.it April 28, 2015 Introduction The bash command shell
More informationUNIX System Programming Lecture 3: BASH Programming
UNIX System Programming Outline Filesystems Redirection Shell Programming Reference BLP: Chapter 2 BFAQ: Bash FAQ BMAN: Bash man page BPRI: Bash Programming Introduction BABS: Advanced Bash Scripting Guide
More informationShell Programming (bash)
Shell Programming Shell Programming (bash) Commands run from a file in a subshell A great way to automate a repeated sequence of commands. File starts with #!/bin/bash absolute path to the shell program
More informationCOMS 6100 Class Notes 3
COMS 6100 Class Notes 3 Daniel Solus September 1, 2016 1 General Remarks The class was split into two main sections. We finished our introduction to Linux commands by reviewing Linux commands I and II
More informationIntroduction: What is Unix?
Introduction Introduction: What is Unix? An operating system Developed at AT&T Bell Labs in the 1960 s Command Line Interpreter GUIs (Window systems) are now available Introduction: Unix vs. Linux Unix
More informationAnswers to AWK problems. Shell-Programming. Future: Using loops to automate tasks. Download and Install: Python (Windows only.) R
Today s Class Answers to AWK problems Shell-Programming Using loops to automate tasks Future: Download and Install: Python (Windows only.) R Awk basics From the command line: $ awk '$1>20' filename Command
More informationRichard Mallion. Swift for Admins #TEAMSWIFT
Richard Mallion Swift for Admins #TEAMSWIFT Apple Introduces Swift At the WWDC 2014 Keynote, Apple introduced Swift A new modern programming language It targets the frameworks for Cocoa and Cocoa Touch
More informationIntroduction. Let s start with the first set of slides
Tux Wars Class - 1 Table of Contents 1) Introduction to Linux and its history 2) Booting process of a linux system 3) Linux Kernel 4) What is a shell 5) Bash Shell 6) Anatomy of command 7) Let s make our
More informationProcesses and Shells
Shell ls pico httpd CPU Kernel Disk NIC Processes Processes are tasks run by you or the OS. Processes can be: shells commands programs daemons scripts Shells Processes operate in the context of a shell.
More informationManual Shell Script Linux If Not Exist Directory Does
Manual Shell Script Linux If Not Exist Directory Does Bash can be configured to be POSIX-confor mant by default. and then a much longer manual available using info (usually they refer to the info page
More informationShell Programming Systems Skills in C and Unix
Shell Programming 15-123 Systems Skills in C and Unix The Shell A command line interpreter that provides the interface to Unix OS. What Shell are we on? echo $SHELL Most unix systems have Bourne shell
More informationUnix basics exercise MBV-INFX410
Unix basics exercise MBV-INFX410 In order to start this exercise, you need to be logged in on a UNIX computer with a terminal window open on your computer. It is best if you are logged in on freebee.abel.uio.no.
More informationAppendix A GLOSSARY. SYS-ED/ Computer Education Techniques, Inc.
Appendix A GLOSSARY SYS-ED/ Computer Education Techniques, Inc. $# Number of arguments passed to a script. $@ Holds the arguments; unlike $* it has the capability for separating the arguments. $* Holds
More informationSystem Programming. Session 6 Shell Scripting
System Programming Session 6 Shell Scripting Programming C Programming vs Shell Programming C vs Shell Programming Compilation/Direct execution C Requires compilation while shell script can be directly
More information5/8/2012. Specifying Instructions to the Shell Chapter 8
An overview of shell. Execution of commands in a shell. Shell command-line expansion. Customizing the functioning of the shell. Employing advanced user features. Specifying Instructions to the Shell Chapter
More informationIntroduction to Linux Part 2b: basic scripting. Brett Milash and Wim Cardoen CHPC User Services 18 January, 2018
Introduction to Linux Part 2b: basic scripting Brett Milash and Wim Cardoen CHPC User Services 18 January, 2018 Overview Scripting in Linux What is a script? Why scripting? Scripting languages + syntax
More informationEECS 470 Lab 5. Linux Shell Scripting. Friday, 1 st February, 2018
EECS 470 Lab 5 Linux Shell Scripting Department of Electrical Engineering and Computer Science College of Engineering University of Michigan Friday, 1 st February, 2018 (University of Michigan) Lab 5:
More informationLinux Command Line Interface. December 27, 2017
Linux Command Line Interface December 27, 2017 Foreword It is supposed to be a refresher (?!) If you are familiar with UNIX/Linux/MacOS X CLI, this is going to be boring... I will not talk about editors
More informationLezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi
Lezione 8 Bioinformatica Mauro Ceccanti e Alberto Paoluzzi Dip. Informatica e Automazione Università Roma Tre Dip. Medicina Clinica Università La Sapienza Sommario Shell command language Introduction A
More informationCOMP 4/6262: Programming UNIX
COMP 4/6262: Programming UNIX Lecture 12 shells, shell programming: passing arguments, if, debug March 13, 2006 Outline shells shell programming passing arguments (KW Ch.7) exit status if (KW Ch.8) test
More informationBash Check If Command Line Parameter Exists
Bash Check If Command Line Parameter Exists How to enter the parameters on the command line for this shell script? exit 1 fi if $ERR, then echo $MSG exit 1 fi if ( -d "$NAME" ), then echo "Directory -
More informationShell scripting and system variables. HORT Lecture 5 Instructor: Kranthi Varala
Shell scripting and system variables HORT 59000 Lecture 5 Instructor: Kranthi Varala Text editors Programs built to assist creation and manipulation of text files, typically scripts. nano : easy-to-learn,
More informationIntroduction to shell scripting
Introduction to shell scripting Thomas Röblitz thomasroblitz@usituiono Research Infrastructure Services Group Department for Research Computing (DRC) DRC Course Week, March 25-28, 2014 Outline What is
More informationComposer User Guide. Version
Composer User Guide Version 10.5.0 copyright 2002-2018 Jamf. All rights reserved. Jamf has made all efforts to ensure that this guide is accurate. Jamf 100 Washington Ave S Suite 1100 Minneapolis, MN 55401-2155
More informationdo shell script in AppleScript
Technical Note TN2065 do shell script in AppleScript This Technote answers frequently asked questions about AppleScript s do shell script command, which was introduced in AppleScript 1.8. This technical
More informationSystem Programming. Unix Shells
Content : Unix shells by Dr. A. Habed School of Computer Science University of Windsor adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Introduction 2 Interactive and non-interactive
More informationIntroduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines
Introduction to UNIX Logging in Basic system architecture Getting help Intro to shell (tcsh) Basic UNIX File Maintenance Intro to emacs I/O Redirection Shell scripts Logging in most systems have graphical
More informationLezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell
Lezione 8 Bioinformatica Mauro Ceccanti e Alberto Paoluzzi Esercitazione Introduzione al linguaggio di shell Dip. Informatica e Automazione Università Roma Tre Dip. Medicina Clinica Università La Sapienza
More informationContents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...
Contents Note: pay attention to where you are........................................... 1 Note: Plaintext version................................................... 1 Hello World of the Bash shell 2 Accessing
More informationPhp Scripts If Then Else Linux Bash Shell
Php Scripts If Then Else Linux Bash Shell I am using awk as part of and if then else statement. KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here. I just wrote
More informationOperating System Interaction via bash
Operating System Interaction via bash bash, or the Bourne-Again Shell, is a popular operating system shell that is used by many platforms bash uses the command line interaction style generally accepted
More informationCS 25200: Systems Programming. Lecture 10: Shell Scripting in Bash
CS 25200: Systems Programming Lecture 10: Shell Scripting in Bash Dr. Jef Turkstra 2018 Dr. Jeffrey A. Turkstra 1 Lecture 10 Getting started with Bash Data types Reading and writing Control loops Decision
More informationPlatform Migrator Technical Report TR
Platform Migrator Technical Report TR2018-990 Munir Contractor mmc691@nyu.edu Christophe Pradal christophe.pradal@inria.fr Dennis Shasha shasha@cs.nyu.edu May 12, 2018 CONTENTS: 1 Abstract 4 2 Platform
More informationShell Scripting. With Applications to HPC. Edmund Sumbar Copyright 2007 University of Alberta. All rights reserved
AICT High Performance Computing Workshop With Applications to HPC Edmund Sumbar research.support@ualberta.ca Copyright 2007 University of Alberta. All rights reserved High performance computing environment
More informationManual Shell Script Linux If Not Equals. Statement >>>CLICK HERE<<<
Manual Shell Script Linux If Not Equals Statement The bash shell supports if and switch (case) decision statements. else ### series of code if the condition is not satisfied fi. Multiple if condition:
More informationToday. Review. Unix as an OS case study Intro to Shell Scripting. What is an Operating System? What are its goals? How do we evaluate it?
Today Unix as an OS case study Intro to Shell Scripting Make sure the computer is in Linux If not, restart, holding down ALT key Login! Posted slides contain material not explicitly covered in class 1
More informationsottotitolo A.A. 2016/17 Federico Reghenzani, Alessandro Barenghi
Titolo presentazione Piattaforme Software per la Rete sottotitolo BASH Scripting Milano, XX mese 20XX A.A. 2016/17, Alessandro Barenghi Outline 1) Introduction to BASH 2) Helper commands 3) Control Flow
More informationUseful Unix Commands Cheat Sheet
Useful Unix Commands Cheat Sheet The Chinese University of Hong Kong SIGSC Training (Fall 2016) FILE AND DIRECTORY pwd Return path to current directory. ls List directories and files here. ls dir List
More informationCS Unix Tools & Scripting
Cornell University, Spring 2014 1 February 21, 2014 1 Slides evolved from previous versions by Hussam Abu-Libdeh and David Slater Announcement HW 4 is out. Due Friday, February 28, 2014 at 11:59PM. Wrapping
More informationCS246 Spring14 Programming Paradigm Notes on Linux
1 Unix History 1965: Researchers from Bell Labs and other organizations begin work on Multics, a state-of-the-art interactive, multi-user operating system. 1969: Bell Labs researchers, losing hope for
More informationBash command shell language interpreter
Principles of Programming Languages Bash command shell language interpreter Advanced seminar topic Louis Sugy & Baptiste Thémine Presentation on December 8th, 2017 Table of contents I. General information
More informationShells and Shell Programming
Shells and Shell Programming 1 Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed
More informationTable of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs
Summer 2010 Department of Computer Science and Engineering York University Toronto June 29, 2010 1 / 36 Table of contents 1 2 3 4 2 / 36 Our goal Our goal is to see how we can use Unix as a tool for developing
More informationLearn Bash The Hard Way
Learn Bash The Hard Way An introduction to Bash using 'The Hard Way' method. 1 Chapter 1. Core Git This bash course has been written to help bash users to get to a deeper understanding and proficiency
More informationShells and Shell Programming
Shells and Shell Programming Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed
More informationLinux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2
Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades 2017-2018 Q2 Facultat d Informàtica de Barcelona This first lab session is focused on getting experience in working
More informationOperating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing
Content 3 Operating Systems The concept of an operating system. The internal architecture of an operating system. The architecture of the Linux operating system in more detail. How to log into (and out
More informationOperating Systems. Copyleft 2005, Binnur Kurt
3 Operating Systems Copyleft 2005, Binnur Kurt Content The concept of an operating system. The internal architecture of an operating system. The architecture of the Linux operating system in more detail.
More informationShells & Shell Programming (Part B)
Shells & Shell Programming (Part B) Software Tools EECS2031 Winter 2018 Manos Papagelis Thanks to Karen Reid and Alan J Rosenthal for material in these slides CONTROL STATEMENTS 2 Control Statements Conditional
More informationEECS 2031E. Software Tools Prof. Mokhtar Aboelaze
EECS 2031 Software Tools Prof. Mokhtar Aboelaze Footer Text 1 EECS 2031E Instructor: Mokhtar Aboelaze Room 2026 CSEB lastname@cse.yorku.ca x40607 Office hours TTH 12:00-3:00 or by appointment 1 Grading
More informationProcesses. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms:
Processes The Operating System, Shells, and Python Shell Commands a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms: - Command prompt - Shell - CLI Shell commands
More informationCS197U: A Hands on Introduction to Unix
CS197U: A Hands on Introduction to Unix Lecture 11: WWW and Wrap up Tian Guo University of Massachusetts Amherst CICS 1 Reminders Assignment 4 was graded and scores on Moodle Assignment 5 was due and you
More informationLinux Systems Administration Getting Started with Linux
Linux Systems Administration Getting Started with Linux Network Startup Resource Center www.nsrc.org These materials are licensed under the Creative Commons Attribution-NonCommercial 4.0 International
More informationManual Shell Script Linux If File Exists And
Manual Shell Script Linux If File Exists And Is Not Empty read Bash Conditional Expressions in the manual, and use the -r and -w operators glenn jackman Dec 10 '14 at -s FILE True if file exists and is
More informationChapter 9. Shell and Kernel
Chapter 9 Linux Shell 1 Shell and Kernel Shell and desktop enviroment provide user interface 2 1 Shell Shell is a Unix term for the interactive user interface with an operating system A shell usually implies
More informationScripting Languages Course 1. Diana Trandabăț
Scripting Languages Course 1 Diana Trandabăț Master in Computational Linguistics - 1 st year 2017-2018 Today s lecture Introduction to scripting languages What is a script? What is a scripting language
More informationWelcome to the Bash Workshop!
Welcome to the Bash Workshop! If you prefer to work on your own, already know programming or are confident in your abilities, please sit in the back. If you prefer guided exercises, are completely new
More informationWhy Bourne Shell? A Bourne Shell Script. The UNIX Shell. Ken Wong Washington University. The Bourne Shell (CSE 422S)
The Bourne Shell (CSE 422S) Ken Wong Washington University kenw@wustl.edu www.arl.wustl.edu/~kenw The UNIX Shell A shell is a command line interpreter» Translates commands typed at a terminal (or in a
More informationIntroduction to Linux Workshop 1
Introduction to Linux Workshop 1 The George Washington University SEAS Computing Facility Created by Jason Hurlburt, Hadi Mohammadi, Marco Suarez hurlburj@gwu.edu Logging In The lab computers will authenticate
More informationUNIX shell scripting
UNIX shell scripting EECS 2031 Summer 2014 Przemyslaw Pawluk June 17, 2014 What we will discuss today Introduction Control Structures User Input Homework Table of Contents Introduction Control Structures
More informationWelcome to the Bash Workshop!
Welcome to the Bash Workshop! If you prefer to work on your own, already know programming or are confident in your abilities, please sit in the back. If you prefer guided exercises, are completely new
More informationLecture 02 The Shell and Shell Scripting
Lecture 02 The Shell and Shell Scripting In this course, we need to be familiar with the "UNIX shell". We use it, whether bash, csh, tcsh, zsh, or other variants, to start and stop processes, control the
More informationCSCI2467: Systems Programming Concepts
CSCI2467: Systems Programming Concepts Class activity: bash shell literacy Instructor: Matthew Toups Fall 2017 Today 0 Shells History Usage Scripts vs. Programs 1 Bash shell: practical uses for your systems
More informationCISC 220 fall 2011, set 1: Linux basics
CISC 220: System-Level Programming instructor: Margaret Lamb e-mail: malamb@cs.queensu.ca office: Goodwin 554 office phone: 533-6059 (internal extension 36059) office hours: Tues/Wed/Thurs 2-3 (this week
More informationRHCE BOOT CAMP. System Administration
RHCE BOOT CAMP System Administration NAT CONFIGURATION NAT Configuration, eth0 outside, eth1 inside: sysctl -w net.ipv4.ip_forward=1 >> /etc/sysctl.conf iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
More informationIntroduction to UNIX Command Line
Introduction to UNIX Command Line Files and directories Some useful commands (echo, cat, grep, find, diff, tar) Redirection Pipes Variables Background processes Remote connections (e.g. ssh, curl) Scripts
More informationCS Unix Tools & Scripting
Cornell University, Spring 2014 1 February 24, 2014 1 Slides evolved from previous versions by Hussam Abu-Libdeh and David Slater A note on awk for (item in array) The order in which items are returned
More informationCS Unix Tools. Lecture 3 Making Bash Work For You Fall Hussam Abu-Libdeh based on slides by David Slater. September 13, 2010
Lecture 3 Making Bash Work For You Fall 2010 Hussam Abu-Libdeh based on slides by David Slater September 13, 2010 A little homework Homework 1 out now Due on Thursday at 11:59PM Moving around and GNU file
More informationI/O and Shell Scripting
I/O and Shell Scripting File Descriptors Redirecting Standard Error Shell Scripts Making a Shell Script Executable Specifying Which Shell Will Run a Script Comments in Shell Scripts File Descriptors Resources
More informationShell Programming Overview
Overview Shell programming is a way of taking several command line instructions that you would use in a Unix command prompt and incorporating them into one program. There are many versions of Unix. Some
More informationEECS2301. Lab 1 Winter 2016
EECS2301 Lab 1 Winter 2016 Lab Objectives In this lab, you will be introduced to the Linux operating system. The basic commands will be presented in this lab. By the end of you alb, you will be asked to
More information3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples
EECS2301 Title Unix/Linux Introduction These slides are based on slides by Prof. Wolfgang Stuerzlinger at York University Warning: These notes are not complete, it is a Skelton that will be modified/add-to
More informationEssential Skills for Bioinformatics: Unix/Linux
Essential Skills for Bioinformatics: Unix/Linux SHELL SCRIPTING Overview Bash, the shell we have used interactively in this course, is a full-fledged scripting language. Unlike Python, Bash is not a general-purpose
More informationCSE II-Sem)
1 2 a) Login to the system b) Use the appropriate command to determine your login shell c) Use the /etc/passwd file to verify the result of step b. d) Use the who command and redirect the result to a file
More informationLast Time. on the website
Last Time on the website Lecture 6 Shell Scripting What is a shell? The user interface to the operating system Functionality: Execute other programs Manage files Manage processes Full programming language
More informationThe Command Line. Matthew Bender. Friday 18 th September, CMSC Command Line Workshop
The Command Line Matthew Bender CMSC Command Line Workshop Friday 18 th September, 2015 Matthew Bender (2015) The Command Line Friday 18 th September, 2015 1 / 51 Shells Section 1 Shells Matthew Bender
More informationBashed One Too Many Times. Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009
Bashed One Too Many Times Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009 What is a Shell? The shell interprets commands and executes them It provides you with an environment
More informationManual Shell Script Linux If File Exists Wildcard
Manual Shell Script Linux If File Exists Wildcard This page shows common errors that Bash programmers make. If $file has wildcards in it (* or? or (), they will be expanded if there are files that match
More informationLinux shell scripting intro/review
Linux shell scripting intro/review David Morgan You should already know how to log in run programs at the command line use pipelines and redirection ( < > ) put jobs in the background ( & ) create and
More informationPractical Computing-II. Programming in the Linux Environment. 0. An Introduction. B.W.Gore. March 20, 2015
Practical Computing-II March 20, 2015 0. An Introduction About The Course CMS M.2.2 Practical Computing-II About The Course CMS M.2.2 Practical Computing-II 25 credits (33.33% weighting) About The Course
More informationUnix Guide. Meher Krishna Patel. Created on : Octorber, 2017 Last updated : December, More documents are freely available at PythonDSP
Unix Guide Meher Krishna Patel Created on : Octorber, 2017 Last updated : December, 2017 More documents are freely available at PythonDSP Table of contents Table of contents i 1 Unix commands 1 1.1 Unix
More informationPerl and R Scripting for Biologists
Perl and R Scripting for Biologists Lukas Mueller PLBR 4092 Course overview Linux basics (today) Linux advanced (Aure, next week) Why Linux? Free open source operating system based on UNIX specifications
More informationMore Scripting and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1
More Scripting and Regular Expressions Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 Regular Expression Summary Regular Expression Examples Shell Scripting 2 Do not confuse filename globbing
More informationShell script. Shell Scripts. A shell script contains a sequence of commands in a text file. Shell is an command language interpreter.
Shell Scripts A shell script contains a sequence of commands in a text file. Shell is an command language interpreter. Shell executes commands read from a file. Shell is a powerful programming available
More information