0% found this document useful (0 votes)
58 views

UNIT 3 Scripting Language

Uploaded by

mtejaswini368
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

UNIT 3 Scripting Language

Uploaded by

mtejaswini368
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Scripting Languages

Dr. Dilshad Ansari,


Dept of CSE,
CMR College of Engineering & Technology
Email :- [email protected]
Mob: +91-9816387077
Unit III
Introduction to PERL and Scripting Scripts and Programs,
Origin of Scripting, Scripting Today, Characteristics of
Scripting Languages, Uses for Scripting Languages, Web
Scripting, and the universe of Scripting Languages. PERL-
Names and Values, Variables, Scalar Expressions, Control
Structures, arrays, list, hashes, strings, pattern and regular
expressions, subroutines
Programming Scripting
 Programming languages are compiled to  Scripting languages have evolved to
machine code and run on the hardware become powerful. Now they are not
of the underlying Operating system. One limited to create small scripts to
must use a certain IDE (Integrated automate operations on a software
Development Environment) to make use system. One can also build a rich
of programming languages. The application with scripting languages. It
programmer provides a set of can manipulate, customize and automate
instructions for a computer to achieve a the facilities of an existing system. Useful
certain goal. Certain algorithms can also functionality is already available via an
be implemented by writing programs. interface; scripting languages provide a
mechanism for exposing functionality to
program control.
Scripts and Programs
1. Script is interpreted by Interpreter 1. Program is compiled by compiler
2. Scripts can control another business 2. Program executed independently without
applications the influence of another application
Example Example
 PHP controls web server
C, C++,JAVA, C#, etc.
 Java Script controls web browser
Applications:
 VB controls MS office application 1. They typically run inside a parent program
3. Script can not executed as stand-alone like scripts
Ex. Ruby, Python, R, Perl, Java script,
PHP, VB, TCL etc.. 2. More compatible while integrating code
Applications: with mathematical models
1.To automate certain tasks in a program
2. Extracting information from a data set
3. Languages like JAVA can be compiled and
3. Less code as compared to traditional then used on any platform.
programming languages
Origins of Scripting
 Basically the use of the word ‘script’ in an  Other early occurrences of the term ‘script’ can
UNIX operating system create the term ‘shell be found. For example, in a DOS-based system,
script’ for sequence of commands that were use of a dial-up connection to a remote system
to be read from a file and follow in sequence required a communication package that used
as if they had been typed in at the keyword. proprietary language to write scripts to
automate the sequence of operations required
 The name ‘script ‘ being used for a text file to establish a connection to a remote system.
that was intended to be executed directly  Note that if we regard a scripts as a sequence of
rather than being compiled to a different commands to control an application or a
form of file prior to execution. device, a configuration file such as a UNIX
‘make file’ could be regard as a script.
 However, scripts only become interesting when
they have the added value that comes from
using programming concepts such as loops and
branches
scripting languages?
 A scripting language is a programming Types of scripting languages
language that executes tasks within a special There are two main types: server-side and
run-time environment by an interpreter client-side. They differ on where the code is
instead of a compiler. They are usually short, run from, which affects not only the actual
fast, and interpreted from source code or languages chosen but also the performance
bytecode. and their capabilities.
 Using a scripting language is preferable
depending on your goals and environment. As
they are a series of commands executed with no
1. Server-side scripting language
need for a compiler, they are cross-platform and 2. Client-side scripting language
do not require special software to be installed in
order to run — except for a web browser, of
course.
Types of S L
 Server-side scripting language:-

 The term server-side scripting language refers to those that run off a web
server. Since it performs from the back-end side, the script is not visible
to the visitor. Because of that, it is a more secure approach.

 They are often used to create dynamic websites and platforms, handle
user queries, and generate and provide data and others. A famous
example of server-side scripting is the use of PHP in WordPress.
 Examples: PHP, Python, Node.js, Perl, and Ruby.
Types of S L
Client-side scripting language:

 Unlike the above, client-side scripting languages run off the user’s
browser. It is usually performed at the front-end, which makes it visible
to visitors and makes it less vulnerable to exploits and leaks. As such, it is
often used to build user interfaces and lighter functionality such as that.
 Since it runs locally, they usually provide better performance and,
therefore, do not strain your server.

 Examples: HTML, CSS, jQuery, and JavaScript.


Scripting Today

 Scripting allows application to be developed much faster than


traditional methods.
 Use to manipulate, customize, automate the existing system
 EXAMPLE. Use of client side scripting and Making dynamic HTML for
interactive and feature rich enhanced web pages
 UNIX OS used shell script for system management for administration
aspect
 Apache web server has an embedded PERL interpreter for CGI scripts
Scripting Today contd..
Characteristics of Scripting Languages
 Integrated Compile and Run:  Enhanced Functionality:
 SL are characterized as interpreted  provide string manipulation based on the
languages. use of regular expressions, while other
 SL operate on an immediate execution languages provide easy access to low-level
basis, without the need to issue separate operating system facilities or to the API,
commands to compile the program and or object exported by an application
then to run the resulting object file, and  Efficiency is not an issue:
without the need to link extensive
 Abstraction:
libraries into the object code.
 Information hiding, to spare users the
 Low overhead and ease of use: details of internal variable types, data
 Less no.of data types storage, and memory management.
 Less no. of data structures
Web Scripting
 Web is the most fertile areas for the application of scripting languages.
 Web scripting divides into three areas
a. processing forms
b. creating pages with enhanced visual effects and user interaction
c. generating pages ’on the fly’ from material held in database.
Web Scripting Contd..
Processing Web forms: In the original implementation of the web ,
when the form is submitted for processing, the information entered
by the user is encoded and sent to the server for processing by a CGI  Dynamically generated HTML:
script that generates an HTML page to be sent back to the Web Another form of dynamic Web page is
browser. This processing requires string manipulation to construct the one in which some or all of the HTML
HTML page that constitutes the replay, and may also require system
access , to run other processes and to establish network connections.
is generated by scripts executed on the
Perl is also a language that uses CGI scripting. Alternatively for server. A common application of the
processing the form with script running on the server it possible to do technique is to construct pages whose
some client –side processing within the browser to validate form data content is retrieved from a database.
before sending it to the server by using JavaScript, VBScript etc.
For example, Microsoft’s IIS web
Dynamic Web pages: ‘Dynamic HTML’ makes every component of
server implements Active Server Pages
a Web page (headings, anchors, tables etc.) a scriptable object. This (ASP), which incorporate scripts in
makes it possible to provide simple interaction with the user using Jscript or VBScript
scripts written in JavaScript/Jscript or VBScript, which are
interpreted by the browser. Microsoft’s ActiveX technology allows the
creation of pages with more elaborate user interaction by using
embedded visual objects called ActiveX controls. These controls are
scriptable objects, and can in fact be scripted in a variety languages.
This can be scripted by using Perl scripting engine.
Uses of Scripting Languages
 A scripting language is a programming language designed for integrating and
communicating with other programming languages.
 The scripting language is basically a language where instructions are written for a
run time environment.
 They do not require the compilation step and are rather interpreted. It brings new
functions to applications and glue complex system together.
Uses of Scripting Languages Contd..
 bash: It is a scripting language to work in the Linux interface. It is a lot easier to use bash to create
scripts than other programming languages. It describes the tools to use and code in the command line
and create useful reusable scripts and conserve documentation for other people to work with.
 Node js: It is a framework to write network applications using JavaScript. Corporate users of
Node.js include IBM, LinkedIn, Microsoft, Netflix, PayPal,Yahoo for real-time web applications.
 Ruby: There are a lot of reasons to learn Ruby programming language. Ruby’s flexibility has allowed
developers to create innovative software. It is a scripting language which is great for web development.
 Python: It is easy, free and open source. It supports procedure-oriented programming and object-
oriented programming. Python is an interpreted language with dynamic semantics and huge lines of
code are scripted and is currently the most hyped language among developers.
 Perl: A scripting language with innovative features to make it different and popular. Found on all
windows and Linux servers. It helps in text manipulation tasks. High traffic websites that use Perl
extensively include priceline.com, IMDB.
Uses of Scripting Languages Contd..
 advantages of scripting languages:
 Easy learning: The user can learn to code in scripting languages quickly, not much knowledge of web
technology is required.
 Fast editing: It is highly efficient with the limited number of data structures and variables to use.
 Interactivity: It helps in adding visualization interfaces and combinations in web pages. Modern web pages
demand the use of scripting languages. To create enhanced web pages, fascinated visual description which
includes background and foreground colors and so on.
 Functionality: There are different libraries which are part of different scripting languages. They help in
creating new applications in web browsers and are different from normal programming languages.
 Application of Scripting Languages: Scripting languages are used in many areas:
 Scripting languages are used in web applications. It is used in server side as well as client side. Server side
scripting languages are: JavaScript, PHP, Perl etc. and client side scripting languages are: JavaScript, AJAX,
jQuery etc.
 Scripting languages are used in system administration. For example: Shell, Perl, Python scripts etc.
 It is used in Games application and Multimedia.
 It is used to create plugins and extensions for existing applications.
Installation Steps for perl
 Step1: Download perl
https://www.activestate.com/products/activeperl/downloads/
 step2: To check if you have perl installed on a Windows PC, search in the start bar
for Perl or run the following on the Command Line (cmd.exe): C:\Users\Your
Name>perl --version
 Step3: change by default path from current working directory to below path
 c:/>cd perl
 C:/>cd scripts
 Step4: C:\Users\Your Name>perl sample.pl
Installation Steps for perl
Script:
#test demo
print "Enter your name: ";
$name=<STDIN>;
print "Hello ${name}";
Installation Steps for Ruby
 Step1: Download Ruby
 https://www.ruby-lang.org/en/downloads/
 step2: To check if you have Ruby installed on a Windows PC, search in the start bar
for Ruby or run the following on the Command Line (cmd.exe): C:\Users\Your
Name>Ruby --version
 Step3: change by default path from current working directory to below path
 c:/>cd ruby
 C:/>cd scripts
 Step4: C:\Users\Your Name>ruby sample.rb

You might also like