Yolinux.com logo

Scripting Languages, CGI Server Scripting and Site Management Tools

Scripting language comparissons, links, tools and CGI web page scripting facilities for the creation, publishing and management of web content.

Contents:


Related YoLinux Tutorials:

°Linux Networking

°Linux Sys Admin

°Internet Security

°Security Tools

°Web site configuration

°Web Tricks

°Internet Gateway

°YoLinux Tutorials Index




Free Information Technology Magazines and Document Downloads
TradePub link image


PERL Tools/Links:

Hello World CGI example: /var/www/cgi-bin/hello.cgi

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<html><body>\n";
print "<h1>Hello World</h1>\n";
print "</body></html>\n";
Note:
  • The file must be executable: chmod +x /var/www/cgi-bin/hello.cgi
  • Start the web server: service httpd start
  • Access through the url: http://localhost/cgi-bin/hello.cgi
  • The above paths reflect Red Hat/Fedora/CentOS. For Ubuntu and other Linux distributions see the YoLinux.com Web site configuration tutorial for the Apache web server configuration.

Form CGI example:

HTML source Perl CGI
<html>
<body>
<form action="http://localhost/cgi-bin/form.cgi" 
      method="POST">
  <p>
  Text: 
  <input type="text" size="20" name="TextLine">
  <input type="submit" name="Button" value="Submit">
  </p>
</form>
</body>
</html>
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<html><body>\n";
print "<h1>Form Info:</h1>\n";

my($buffer);
my(@pairs);
my($pair);
read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
   {
   print "$pair<br>\n"
   }
print "</body></html>\n";
Note:
  • Extra handling is required for URL "+", ASCII conversion of spaces "%20" and other web encoding.
  • CGI POST method uses stdin.
  • CGI file name: /var/www/cgi-bin/form.cgi

HTML form Results

Text:

Form Info:
TextLine=Hello
Button=Submit
The results are for this example where the text entered in the text field is "Hello".


PHP Tools/Links:


Python:

Learn Python:


Ruby:

Ruby On Rails: Rails uses the Model-View-Controller (MVC) architecture pattern and contains Javascript libraries, AJAX libraries, and RESTful web services. Rails relies on a web server to run it. Rails can be run with Apache (and Lighttpd) using CGI, FastCGI, mod_rails or mod_ruby or with a dedicated platform server such as Mongrel.


Groovy:

Groovy is a scripting language with Java like syntax with features inspired by Python, Ruby and Smalltalk. Groovy seemlessly integrates with all existing Java objects and libraries as it is compiled into Java bytecode and runs in a JVM.


Tcl:

"Tool Command Language" (Tcl) pronounced as "tickle" is a scripting language most often coupled with Tk for rapid prototyping of GUI applications.


Tk:

First introduced as a graphics library for Tcl, Tool Kit (Tk) has been integrated with Perl, Python and Ruby. Tk is used for GUI scripting and not web server scripting but is included here because it is makes scripting languages like Tcl, Perl, Python and Ruby so versatile. Here is a comparison of the use of Tk in Perl, Python, Ruby and Tcl to create the following graphical "Quit" button:

Perl:
#!/usr/bin/perl
use Tk;

# Main Window
my $mw = new MainWindow;

my $but = $mw -> Button(-text => "Quit",
                -command =>\&push_button);
$but -> pack();

MainLoop;

#This is executed when the button is pressed
sub push_button {
        exit;
}
The file must be executable: chmod +x btn.pl
Run: btn.pl

Links:

Python:

Note: Requires the RPM package tkinter
from Tkinter import *

root = Tk()
example = Button(root, text="Quit", command=root.destroy)
example.grid()
root.mainloop()
Run: python btn.py

Links:

Ruby:

require 'tk'
root = TkRoot.new()
button = TkButton.new(root) {
  text "Quit"
  command proc { exit }
}

button.pack()

Tk.mainloop()
Run: ruby btn.py

Links:

Tcl/Tk:

button .b -text "Quit" -command {exit}
pack .b
Run: wish btn.tcl

Links:

Tk Links:


Publishing, Site Management, Scripting Tools:


Links:


Books:

"Programming Perl"
by Larry Wall, Tom Christiansen, Jon Orwant
ISBN # 0596000278, O'Reilly & Associates

This book teaches you PERL and is also a good reference.

Amazon.com
"Advanced PERL Programming"
by Sriram Srinivasan
ISBN # 1565922204, O'Reilly & Associates

Amazon.com
"CGI Programming with PERL"
by Gunther Birznieks, Scott Guelich, Shishir Gundavaram
ISBN # 1565924193, O'Reilly & Associates

Amazon.com
"Programming with PERL DBI"
by Alligator Descartes, Tim Bunce
ISBN # 1565926994, O'Reilly & Associates

Amazon.com
"Learning PERL Objects, Refences and Modules"
by Randal L. Schwartz, Tom Phoenix
ISBN # 0596004788, O'Reilly & Associates

Amazon.com
"CGI/Perl Cookbook"
by Craig Patchet, Matthew Wright
ISBN # 0471168963, Wiley, John & Son

This book is full of code snippets which you can put together for your own needs.

Amazon.com
"Building Database Applications on the Web Using Php3"
by Craig Hilton,Bjorn Borud,Jeff Willis
ISBN # 0201657716, Addison Wesley Longman

Amazon.com
"Php3 and MySQL for Dynamic Web Sites"
by Larry Ullman
ISBN # 0321186486, Peachpit Press

Amazon.com
"Programming Python: Object-Oriented Scripting"
by Mark Lutz,Foreword by Guido Van Rossum
ISBN # 0596000855, O'Reilly & Associates

Amazon.com
"Programming Ruby: The Pragmatic Programmers Guide, Second Edition"
by Dave Thomas, Chad Fowler, Andy Hunt
ISBN # 0974514055, Pragmatic Bookshelf; 2nd edition (October 1, 2004)

Amazon.com
    Bookmark and Share




YoLinux.com Home Page
YoLinux Tutorial Index
Privacy Policy | Advertise with us | Feedback Form |
Unauthorized copying or redistribution prohibited.

Bookmark and Share

Copyright © 2001 - 2009 by Greg Ippolito