Scripting Languages James Brucker Computer Engineering Dept Kasetsart University.

Slides:



Advertisements
Similar presentations
1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 2 Getting Started.
Advertisements

METALOGIC s o f t w a r e © Metalogic Software Corporation DACS Developer Overview DACS – the Distributed Access Control System.
Introduction to JavaScript
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Test Automation Framework Ashesh Jain 2007EE50403 Manager Amit Maheshwari.
COEN 445 Communication Networks and Protocols Lab 4
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
Software Language Levels Machine Language (Binary) Assembly Language –Assembler converts Assembly into machine High Level Languages (C, Perl, Shell)
Integer variables #!/bin/csh # sum of numbers from $argv[1] to $argv[2] set low = $argv[1] set high = $argv[2] set sum = 0 set current = $low while ( $current.
Scripting Languages CS351 – Programming Paradigms.
Scripting Languages CS351 – Programming Paradigms.
Scripting Languages. Originally, a script was a file containing a sequence of commands that needed to be executed Control structures were added to make.
Unix Shell Scripts. What are scripts ? Text files in certain format that are run by another program Examples: –Perl –Javascript –Shell scripts (we learn.
Chapter 6: Hostile Code Guide to Computer Network Security.
Slide 1 of 9 Presenting 24x7 Scheduler The art of computer automation Press PageDown key or click to advance.
Using Unix Shell Scripts to Manage Large Data
PYTHON: LESSON 1 Catherine and Annie. WHAT IS PYTHON ANYWAY?  Python is a programming language.  But what’s a programming language?  It’s a language.
Shell Programming, or Scripting Shirley Moore CPS 5401 Fall August 29,
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 03.
UFCEKG-20-2 Data, Schemas & Applications Lecture 4 Server Side Scripting & PHP.
Python Mini-Course University of Oklahoma Department of Psychology Day 1 – Lesson 2 Fundamentals of Programming Languages 4/5/09 Python Mini-Course: Day.
UNIX command line. In this module you will learn: What is the computer shell What is the command line interface (or Terminal) What is the filesystem tree.
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
2 1 Sending Data Using a Hyperlink CGI/Perl Programming By Diane Zak.
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 6.
Python Modules An Introduction. Introduction A module is a file containing Python definitions and statements. The file name is the module name with the.
Computer Programming for Biologists Oct 30 th – Dec 11 th, 2014 Karsten Hokamp  Fill out.
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
H3D API Training  Part 3.1: Python – Quick overview.
Writing C-shell scripts #!/bin/csh # Author: Ken Berman # Date: # Purpose: display command and parameters echo $0 echo $argv[*]
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
LINUX System : Lecture 6 Shell Programming
1 Operating Systems Lecture 2 UNIX and Shell Scripts.
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
Intro to Python Adriane Huber Debbie Bartlett Python Lab #1Python Lab #1 1.
Fall 2004CSI University of Ottawa Introduction to PHP Basic principles and syntax.
CS4710 Why Progam?. Why learn to program? Utility of programming skills: understand tools modify tools create your own automate repetitive tasks automate.
Introduction to Unix – CS 21
Unit 1 Basic Python programs, functions Special thanks to Roy McElmurry, John Kurkowski, Scott Shawcroft, Ryan Tucker, Paul Beck for their work. Except.
Programming for GCSE 1.0 Beginning with Python T eaching L ondon C omputing Margaret Derrington KCL Easter 2014.
LIN Unix Lecture 5 Unix Shell Scripts. LIN Command Coordination ; && || command1 ; command2 Interpretation: Do command 1. Then do command.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
Scripting with Ruby What is a scripting language? What is Ruby?
Perl Lab #11 Intro to Perl Debbie Bartlett. Perl Lab #1 2 Perl Practical Extraction and Report Language –or- Pathologically Eclectic Rubbish Lister Created.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
Xi Wang Yang Zhang. 1. Easy to learn 2. Clean and readable codes 3. A lot of useful packages, especially for web scraping and text mining 4. Growing popularity.
1 PHP Intro PHP Introduction After this lecture, you should be able to: Know the fundamental concepts of Web Scripting Languages in general, PHP in particular.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 13 Scott Marino.
PHP stands for …….. “PHP Hypertext Pre-processor” and is a server-side scripting language like ASP. PHP scripts are executed on the server PHP supports.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
Presented By P.SRIVIDYA 085D1A0552 Programming Language.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/9/2006 Lecture 6 – String Processing.
Bash Scripting CIRC Summer School 2016 Baowei Liu CIRC Summer School 2016 Baowei Liu.
PHP Basics and Syntax Lesson 3 ITBS2203 E-Commerce for IT.
Development Environment
CMIT100 Chapter 14 - Programming.
CIRC Winter Boot Camp 2017 Baowei Liu
CS 330 Class 7 Comments on Exam Programming plan for today:
C-Shell with Functions
Using Unix Shell Scripts to Manage Large Data
Scripting for QA Engineers
PERL.
Introduction to Programming the WWW I
INTRODUCTION TO UNIX: The Shell Command Interface
Introduction to computing
Introduction to UNIX.
1 Python Lab #1 Intro to Python Adriane Huber Debbie Bartlett.
Java Applets.
Intro to PHP.
Web Application Development Using PHP
Presentation transcript:

Scripting Languages James Brucker Computer Engineering Dept Kasetsart University

Origins Used to create a list of commands for the operating system to execute. Automate repetative tasks. # Delete all files in the /tmp directory that # have not been used in 7 days. find /tmp -atime +7 -type f -exec rm { } \; File : cleantemp.sh shell> cleantemp.sh

And the script grows... # Delete all files in the /tmp and /var/tmp that # have not been used in 7 days. find /tmp -atime +7 -type f -exec rm { } \; find /var/tmp -atime +7 -type f -exec rm { } \; # Delete all files in several directories # have not been used in 7 days. DIRS="/tmp /var/tmp /var/spool/mqueue" for d in $DIRS; do find $d -atime +7 -type f -exec rm { } \; done

Characteristics of Scripts Issue commands to other program(s). Shell scripts: run operating system commands Embedded script language: customize behavior of an application Example: VBA for MS Office Lisp for Emacs

Original Unix Script Languages /bin/sh – Bourne shell /bin/bash – Bourne-again shell /bin/csh – C-shell (syntax is like C) Using helper commands: grep - find strings in files sed - stream editor find - search for files dirname, filename

Unix Toolkits for Windows Cygwin: MSYS:

DOS "bat" (batch) files are scripts Print the... line in all HTML files. FINDSTR /I /R ".* " *.html

Adding useful message to Batch file Print help if no parameters given Print a message if no matching OFF IF "x%1" == "x" Usage: showtitles filespac [...] GOTO END ) FINDSTR /I /R ".* " %* IF ERRORLEVEL No match found :END

Exercise Write a BAT file to find all occurrences of a given HTML tag. Example: findtags h1

Perl Practical Extraction and Reporting Language Originally for systems admin work on Unix Often used for "CGI" web applications Excellent text processing (regex) support Extensive libraries: CPAN network Disadvantages almost no type checking scripts can be difficult to read not built on O-O foundation

Perl: download and save a URL Download a URL from the web and save it to a local file... without using a web browser! Prerequisite: install LWP module shell> cpan install LWP

Perl: download and save a URL uses LWP getstore( url, filename) function #!/usr/bin/perl # Download a URL and save as a file use LWP::Simple; # get filename from URL $url = $ARGV[0]; if ( $url =~ /.*\/([^\/]+)$/ ) { $file = $1; } else { $file = "noname.html"; } $rc = getstore( $url, $file); if ( is_success( $rc ) ) { print "URL saved as $file\n"; } else { print "Failed. HTTP response code $rc\n"; }

Python: an O-O language Designed as O-O language Supports many common data structures Good C API Named after Monty Python Libraries almost as extensive as Perl Disadvantages uses indentation to denote blocks & scope unusual syntax

Python: download a URL #!/usr/bin/python import urllib import sys if (len(sys.argv) < 2): print "Missing URL name\n" sys.exit(-1) # get a handle for URL url = urllib.urlopen( sys.argv[1] ) # open output file f = open("somefile.html", "w") f.write( url.read() ) f.close() url.close( )

Python: define a class class Person: # constructor def __init__(self, name): salf.name = name # greet the person def greet(self): print "Hello " + self.name #end of the class santa = Person("Santa Claus") santa.greet() # get data type - like Java getClass( ) method print type( santa )

Ruby and Rails Modern script language with many ideas from Perl Completely O-O Killer app: Rails web framework Disadvantages slow weird syntax and multiple commands to do same thing

Ruby: 4 ways to join strings s = "hello " "world" t = "hello " + " world" u = "hello ".concat(" world") v = "hello " << " world" print s print(t) # parenthesis are optional

Groovy Interpreted language based on Java syntax Can import and use any Java class Groovy compiler (groovyc) generates Java.class files! Killer app: Grails web framework

Assignment Learn Python: read install Python interpreter on your notebook