SlideShare a Scribd company logo
Introduction to CGI and PERL CISIWEB 434A
Basic Internet Technology Internet IP address Domain name World Wide Web HTML Web Server Browser URL Static Web Page Vs. Dynamic Web Page
CGI Common Gateway Interface Protocol that allows a server to communicate with CGI scripts Stored in a special directory (CGI-BIN) Can send information to and receive information from databases on the server Creates HTML as output to send to browser window PERL language is most widely used language (but not only language)
What is PERL? Practical Extraction and Report Language Most often used for creating CGI Interesting aside – the language was almost named “gloria” after the wife of Larry Wall, the programs inventor
What do you need? Computer running UNIX or windows Browser software Perl Interpreter A Web server that allows you to create, save, and execute CGI scripts Create your own server on your PC by installing apache or IIS Use an Internet Service Provider to host your site given that they support CGI Example:  http://www.netfirms.com
Create the Bin and Set permissions Almost sounds like another language? Create a folder to put your files Commonly named cgi-bin Common gateway interface – binary UNIX mkdir cgi-bin Chmod should be set to 755 Owner can read(4), write(2), execute(1) Group and others can read and execute UNIX command chmod 755 cgi-bin
How to write a CGI Script First locate perl interpreter UNIX – usually /usr/bin/perl Windows – C:/Perl/bin/perl.exe Use a text editor to create your file – Notepad or wordpad in windows Start with shebang line # ( Sh arp) !(bang symbol) Location of the Perl Interpreter Ex:  #!/usr/bin/perl
Sample CGI code, pg 8 Shebang line Comment – starts with a # sign, will be ignored by the interpreter Interpreter sends information to the server which will send to the browser so results need to be in proper format for browser (html) Content-type header Print “Content-type: text/html\n\n”; Other types?  text/plain or image/gif /n/n, ends the line, adds a blank line Ends with semi colon, completes the statement
Use Perl to generate html Use Print to create statements with html strings Enclose html in quotes End statement with semi-colon
Getting the script to work on the server You have to send the script to the server using ftp Be sure to send the file as ascii Make sure the document is a text file with a cgi extension
Testing a script Testing locally using PERL interpreter Find a command prompt Change directory to cgi-bin Type perl –c file.cgi Perl starts the perl interpreter -c checks the syntax without executing File.cgi is the name of the text script created
Testing a script Testing the file on a server Run the file as  http://yourservername/cgi-bin/file.cgi Press enter – browser submits the url to the server and runs the script which calls the interpreter to convert the instructions to machine code View page source, only the HTML is returned as a result of the PERL
Ad

More Related Content

What's hot (20)

Java servlets and CGI
Java servlets and CGIJava servlets and CGI
Java servlets and CGI
lavanya marichamy
 
Cgi
CgiCgi
Cgi
DEEPIKA KAMBOJ
 
Web Development in Perl
Web Development in PerlWeb Development in Perl
Web Development in Perl
Naveen Gupta
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
Zoran Jeremic
 
Perl in the Internet of Things
Perl in the Internet of ThingsPerl in the Internet of Things
Perl in the Internet of Things
Dave Cross
 
Develop webservice in PHP
Develop webservice in PHPDevelop webservice in PHP
Develop webservice in PHP
Sanil Subhash Chandra Bose
 
Linux Apache Php Mysql Lamp1273
Linux Apache Php Mysql Lamp1273Linux Apache Php Mysql Lamp1273
Linux Apache Php Mysql Lamp1273
hussulinux
 
[WSO2Con EU 2017] An Overview of Ballerina Composer
[WSO2Con EU 2017] An Overview of Ballerina Composer[WSO2Con EU 2017] An Overview of Ballerina Composer
[WSO2Con EU 2017] An Overview of Ballerina Composer
WSO2
 
PHP and Web Services
PHP and Web ServicesPHP and Web Services
PHP and Web Services
Bruno Pedro
 
[WSO2Con EU 2017] Exploring Ballerina Toolset
[WSO2Con EU 2017] Exploring Ballerina Toolset[WSO2Con EU 2017] Exploring Ballerina Toolset
[WSO2Con EU 2017] Exploring Ballerina Toolset
WSO2
 
Creating And Consuming Web Services In Php 5
Creating And Consuming Web Services In Php 5Creating And Consuming Web Services In Php 5
Creating And Consuming Web Services In Php 5
Michael Girouard
 
Server Side Programming
Server Side ProgrammingServer Side Programming
Server Side Programming
Milan Thapa
 
Ldap2010
Ldap2010Ldap2010
Ldap2010
CYJ
 
Server side programming
Server side programming Server side programming
Server side programming
javed ahmed
 
ASP.NET Core 3.0 Deep Dive
ASP.NET Core 3.0 Deep DiveASP.NET Core 3.0 Deep Dive
ASP.NET Core 3.0 Deep Dive
Jon Galloway
 
Server side programming
Server side programmingServer side programming
Server side programming
Sayed Ahmed
 
10 Reasons ColdFusion PDFs should rule the world
10 Reasons ColdFusion PDFs should rule the world10 Reasons ColdFusion PDFs should rule the world
10 Reasons ColdFusion PDFs should rule the world
ColdFusionConference
 
Starting With Php
Starting With PhpStarting With Php
Starting With Php
Harit Kothari
 
Drupal users group_symfony2
Drupal users group_symfony2Drupal users group_symfony2
Drupal users group_symfony2
Brian Zitzow
 
Php 5.5
Php 5.5Php 5.5
Php 5.5
Naseer Ahmad
 
Web Development in Perl
Web Development in PerlWeb Development in Perl
Web Development in Perl
Naveen Gupta
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
Zoran Jeremic
 
Perl in the Internet of Things
Perl in the Internet of ThingsPerl in the Internet of Things
Perl in the Internet of Things
Dave Cross
 
Linux Apache Php Mysql Lamp1273
Linux Apache Php Mysql Lamp1273Linux Apache Php Mysql Lamp1273
Linux Apache Php Mysql Lamp1273
hussulinux
 
[WSO2Con EU 2017] An Overview of Ballerina Composer
[WSO2Con EU 2017] An Overview of Ballerina Composer[WSO2Con EU 2017] An Overview of Ballerina Composer
[WSO2Con EU 2017] An Overview of Ballerina Composer
WSO2
 
PHP and Web Services
PHP and Web ServicesPHP and Web Services
PHP and Web Services
Bruno Pedro
 
[WSO2Con EU 2017] Exploring Ballerina Toolset
[WSO2Con EU 2017] Exploring Ballerina Toolset[WSO2Con EU 2017] Exploring Ballerina Toolset
[WSO2Con EU 2017] Exploring Ballerina Toolset
WSO2
 
Creating And Consuming Web Services In Php 5
Creating And Consuming Web Services In Php 5Creating And Consuming Web Services In Php 5
Creating And Consuming Web Services In Php 5
Michael Girouard
 
Server Side Programming
Server Side ProgrammingServer Side Programming
Server Side Programming
Milan Thapa
 
Ldap2010
Ldap2010Ldap2010
Ldap2010
CYJ
 
Server side programming
Server side programming Server side programming
Server side programming
javed ahmed
 
ASP.NET Core 3.0 Deep Dive
ASP.NET Core 3.0 Deep DiveASP.NET Core 3.0 Deep Dive
ASP.NET Core 3.0 Deep Dive
Jon Galloway
 
Server side programming
Server side programmingServer side programming
Server side programming
Sayed Ahmed
 
10 Reasons ColdFusion PDFs should rule the world
10 Reasons ColdFusion PDFs should rule the world10 Reasons ColdFusion PDFs should rule the world
10 Reasons ColdFusion PDFs should rule the world
ColdFusionConference
 
Drupal users group_symfony2
Drupal users group_symfony2Drupal users group_symfony2
Drupal users group_symfony2
Brian Zitzow
 

Viewers also liked (20)

CGI Corporate PPT
CGI Corporate PPTCGI Corporate PPT
CGI Corporate PPT
jhurtadorojo
 
Computer Generated Imagery (CGI)
Computer Generated Imagery (CGI)Computer Generated Imagery (CGI)
Computer Generated Imagery (CGI)
Pribhat Sharma
 
Présentation CGI/Logica
Présentation CGI/LogicaPrésentation CGI/Logica
Présentation CGI/Logica
studyka
 
Happy Holidays & Prosperity Card
Happy Holidays & Prosperity CardHappy Holidays & Prosperity Card
Happy Holidays & Prosperity Card
CGI
 
TelNet
TelNetTelNet
TelNet
Rahul kRISHNAN
 
Keynote #Enterprise - EDF, retours sur quelques années d'achats open source, ...
Keynote #Enterprise - EDF, retours sur quelques années d'achats open source, ...Keynote #Enterprise - EDF, retours sur quelques années d'achats open source, ...
Keynote #Enterprise - EDF, retours sur quelques années d'achats open source, ...
Paris Open Source Summit
 
Telnet
TelnetTelnet
Telnet
Jishnu Pradeep
 
Computer generated images in movies
Computer generated images in moviesComputer generated images in movies
Computer generated images in movies
Stephen Halley
 
What is eBusiness
What is eBusinessWhat is eBusiness
What is eBusiness
Carol Skyring
 
Web browser
Web browserWeb browser
Web browser
Hardik Kakadiya
 
e-Business
e-Businesse-Business
e-Business
Biplab Mukherjee
 
The World Wide Web Power Point
The World Wide Web Power PointThe World Wide Web Power Point
The World Wide Web Power Point
karamfilova
 
Web Browsers
Web BrowsersWeb Browsers
Web Browsers
Aahmed Hussain
 
Electronic payment System
Electronic payment SystemElectronic payment System
Electronic payment System
Rajat Sharma
 
Electronic Payment Systems (EPS)
Electronic Payment Systems (EPS)Electronic Payment Systems (EPS)
Electronic Payment Systems (EPS)
Sahan Walpitagamage
 
Final ppt of e business
Final ppt of e businessFinal ppt of e business
Final ppt of e business
Abhishek Raj
 
E Payment
E PaymentE Payment
E Payment
Ankit Saxena
 
E-business
E-businessE-business
E-business
Ramakrishna Kongalla
 
E business ppt
E business pptE business ppt
E business ppt
Mayank Kumar
 
Firewall
Firewall Firewall
Firewall
Amuthavalli Nachiyar
 
Ad

Similar to CGI Introduction (20)

programming language interface i.pptx
programming language interface    i.pptxprogramming language interface    i.pptx
programming language interface i.pptx
urvashipundir04
 
Dynamic Web Programming
Dynamic Web ProgrammingDynamic Web Programming
Dynamic Web Programming
Information Technology
 
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
Lecture 10 software development
Lecture 10 software developmentLecture 10 software development
Lecture 10 software development
Jehanzaib Yousuf
 
introduction to php notes for engineering students.ppt
introduction to php notes for engineering students.pptintroduction to php notes for engineering students.ppt
introduction to php notes for engineering students.ppt
manju451965
 
PHP
PHPPHP
PHP
ARJUN
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
Sleepy Head
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
PHP: Hypertext Preprocessor Introduction
PHP: Hypertext Preprocessor IntroductionPHP: Hypertext Preprocessor Introduction
PHP: Hypertext Preprocessor Introduction
Oto Brglez
 
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to EndIntroduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
christopherneo4
 
Phpwebdevelping
PhpwebdevelpingPhpwebdevelping
Phpwebdevelping
mohamed ashraf
 
PHP LICTURES ..........
PHP LICTURES ..........PHP LICTURES ..........
PHP LICTURES ..........
Rashid Ahmad
 
topic_perlcgi
topic_perlcgitopic_perlcgi
topic_perlcgi
tutorialsruby
 
topic_perlcgi
topic_perlcgitopic_perlcgi
topic_perlcgi
tutorialsruby
 
PHP
PHPPHP
PHP
Jawhar Ali
 
Php unit i
Php unit iPhp unit i
Php unit i
BagavathiLakshmi
 
Apache2 BootCamp : Serving Dynamic Content with CGI
Apache2 BootCamp : Serving Dynamic Content with CGIApache2 BootCamp : Serving Dynamic Content with CGI
Apache2 BootCamp : Serving Dynamic Content with CGI
Wildan Maulana
 
Php
PhpPhp
Php
Nadhi ya
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
Alokin Software Pvt Ltd
 
Phpwebdev
PhpwebdevPhpwebdev
Phpwebdev
Luv'k Verma
 
programming language interface i.pptx
programming language interface    i.pptxprogramming language interface    i.pptx
programming language interface i.pptx
urvashipundir04
 
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
Lecture 10 software development
Lecture 10 software developmentLecture 10 software development
Lecture 10 software development
Jehanzaib Yousuf
 
introduction to php notes for engineering students.ppt
introduction to php notes for engineering students.pptintroduction to php notes for engineering students.ppt
introduction to php notes for engineering students.ppt
manju451965
 
PHP: Hypertext Preprocessor Introduction
PHP: Hypertext Preprocessor IntroductionPHP: Hypertext Preprocessor Introduction
PHP: Hypertext Preprocessor Introduction
Oto Brglez
 
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to EndIntroduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
christopherneo4
 
PHP LICTURES ..........
PHP LICTURES ..........PHP LICTURES ..........
PHP LICTURES ..........
Rashid Ahmad
 
Apache2 BootCamp : Serving Dynamic Content with CGI
Apache2 BootCamp : Serving Dynamic Content with CGIApache2 BootCamp : Serving Dynamic Content with CGI
Apache2 BootCamp : Serving Dynamic Content with CGI
Wildan Maulana
 
Ad

More from Chaffey College (20)

Strings Objects Variables
Strings Objects VariablesStrings Objects Variables
Strings Objects Variables
Chaffey College
 
Ruby Chapter 2
Ruby Chapter 2Ruby Chapter 2
Ruby Chapter 2
Chaffey College
 
Social networks and games
Social networks and gamesSocial networks and games
Social networks and games
Chaffey College
 
Serious games
Serious gamesSerious games
Serious games
Chaffey College
 
Chapter 05
Chapter 05Chapter 05
Chapter 05
Chaffey College
 
Chapter 04
Chapter 04Chapter 04
Chapter 04
Chaffey College
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
Chaffey College
 
The games factory 2 alien wars
The games factory 2 alien warsThe games factory 2 alien wars
The games factory 2 alien wars
Chaffey College
 
Target markets
Target marketsTarget markets
Target markets
Chaffey College
 
Ch 8 introduction to data structures
Ch 8 introduction to data structuresCh 8 introduction to data structures
Ch 8 introduction to data structures
Chaffey College
 
Ch 8 data structures in alice
Ch 8  data structures in aliceCh 8  data structures in alice
Ch 8 data structures in alice
Chaffey College
 
Ch 7 recursion
Ch 7 recursionCh 7 recursion
Ch 7 recursion
Chaffey College
 
Intro to gml
Intro to gmlIntro to gml
Intro to gml
Chaffey College
 
Power point unit d
Power point unit dPower point unit d
Power point unit d
Chaffey College
 
Power point unit c
Power point unit cPower point unit c
Power point unit c
Chaffey College
 
Power point unit b
Power point unit bPower point unit b
Power point unit b
Chaffey College
 
Power point unit a
Power point unit aPower point unit a
Power point unit a
Chaffey College
 
Gamegraphics
GamegraphicsGamegraphics
Gamegraphics
Chaffey College
 
Gamesound
GamesoundGamesound
Gamesound
Chaffey College
 
Ch 6 text and sound in alice
Ch 6 text and sound in aliceCh 6 text and sound in alice
Ch 6 text and sound in alice
Chaffey College
 

CGI Introduction

  • 1. Introduction to CGI and PERL CISIWEB 434A
  • 2. Basic Internet Technology Internet IP address Domain name World Wide Web HTML Web Server Browser URL Static Web Page Vs. Dynamic Web Page
  • 3. CGI Common Gateway Interface Protocol that allows a server to communicate with CGI scripts Stored in a special directory (CGI-BIN) Can send information to and receive information from databases on the server Creates HTML as output to send to browser window PERL language is most widely used language (but not only language)
  • 4. What is PERL? Practical Extraction and Report Language Most often used for creating CGI Interesting aside – the language was almost named “gloria” after the wife of Larry Wall, the programs inventor
  • 5. What do you need? Computer running UNIX or windows Browser software Perl Interpreter A Web server that allows you to create, save, and execute CGI scripts Create your own server on your PC by installing apache or IIS Use an Internet Service Provider to host your site given that they support CGI Example: http://www.netfirms.com
  • 6. Create the Bin and Set permissions Almost sounds like another language? Create a folder to put your files Commonly named cgi-bin Common gateway interface – binary UNIX mkdir cgi-bin Chmod should be set to 755 Owner can read(4), write(2), execute(1) Group and others can read and execute UNIX command chmod 755 cgi-bin
  • 7. How to write a CGI Script First locate perl interpreter UNIX – usually /usr/bin/perl Windows – C:/Perl/bin/perl.exe Use a text editor to create your file – Notepad or wordpad in windows Start with shebang line # ( Sh arp) !(bang symbol) Location of the Perl Interpreter Ex: #!/usr/bin/perl
  • 8. Sample CGI code, pg 8 Shebang line Comment – starts with a # sign, will be ignored by the interpreter Interpreter sends information to the server which will send to the browser so results need to be in proper format for browser (html) Content-type header Print “Content-type: text/html\n\n”; Other types? text/plain or image/gif /n/n, ends the line, adds a blank line Ends with semi colon, completes the statement
  • 9. Use Perl to generate html Use Print to create statements with html strings Enclose html in quotes End statement with semi-colon
  • 10. Getting the script to work on the server You have to send the script to the server using ftp Be sure to send the file as ascii Make sure the document is a text file with a cgi extension
  • 11. Testing a script Testing locally using PERL interpreter Find a command prompt Change directory to cgi-bin Type perl –c file.cgi Perl starts the perl interpreter -c checks the syntax without executing File.cgi is the name of the text script created
  • 12. Testing a script Testing the file on a server Run the file as http://yourservername/cgi-bin/file.cgi Press enter – browser submits the url to the server and runs the script which calls the interpreter to convert the instructions to machine code View page source, only the HTML is returned as a result of the PERL