Download presentation
Presentation is loading. Please wait.
1
Scripting Languages
2
Originally, a script was a file containing a sequence of commands that needed to be executed Control structures were added to make it possible to do more with scripts
3
Characteristics of Scripting Languages Generally interpreted Dynamic typing - no declarations Make text processing easy Often provide pattern matching for strings Provide file and directory manipulation Make it easy to do things quickly
4
Basic Scripting Languages Unix and Linux come with shell programs which are programmable –sh –bash –ksh –csh DOS had BAT files
5
Scripting in Other Environments Even with a GUI operating system, it is still useful to be able to automate repetetive tasks –Windows still has bat files –Mac OS has AppleScript Some applications have a scripting language built into them –Microsoft applications have Visual Basic for Applications (VBA) –Hypercard (Apple) had HyperTalk
6
Other Scripting Languages Other scripting languages were developed to provide increased capability –sed -- adapted from the unix ed editor in 1977 –AWK -- created by Ajo, Wienberger and Kernighan in 1977 –Tcl -- an extensible scripting language written by John Ousterhout in 1987 –Perl -- created by Larry Wall in 1986 –Python-- created in 1989 by Guido van Rossum –Ruby -- created in 1993 by Yukihiro Matsumoto
7
Scripting and the Web More recently, a number of scripting languages have been developed for use with web browsers –PHP –JavaScript –ASP (part of Microsoft.NET framework)
8
Scripting on onyx the shell command languages perl python ruby tcl
9
Scripts on onyx In the following, is the name of the interpreter (perl, python, ruby, tcl) create a file - a script whose first line is #!/usr/bin/ There are man pages for all of these man
10
Running Scripts two ways to run a program –give the name of file containing script to the interpreter prog –make script file executable and type the program name chmod +x script script./script
11
Hello World Perl #!/usr/bin/perl print "Hello, world!\n"; Python #!/usr/bin/python import sys sys.stdout.write("Hello world!\n")
12
Hello World Ruby #!/usr/bin/ruby print "Hello world!\n" Tcl #!/usr/bin/tcl puts "Hello world!"
13
Input Redirection In Linux, you can redirect the contents of a file into your program using the < operator. The command doCommand < infile will send the contents of infile to your program as if it were coming from the keyboard.
14
Input/Output Redirection Similarly, you can use the > operator to send the console output from your program into a file. doCommand > outfile You can do both operations at the same time with doCommand outfile
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.