cgi & perl

The Common Gateway Interface, or CGI, is a standard for external gateway programs to interface with information servers such as HTTP servers, maintained by the NCSA. The current version is CGI/1.1 and CGI/1.2 is under progress.

Essentially, a CGI is just a program which runs on the server. It can be written in any programming language, but Perl has become a popular choice for CGI programming because it is available for all platforms, and it has many useful tools that are ideal for the web. By convention cgi programs have the file extension .cgi.

Perl is an interpreted language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information. It’s also a good language for any system management tasks. The language is intended to be practical rather than beautiful. Perl was created by Larry Wall. Perl scripts have the file extension .pl.

There is no real difference between .cgi and  .pl file extensions. Web servers can be configured for a specific extension or you can even leave off the extension, because it’s the first line called shebang in the script that tells the server where and which interpreter to use. For perl programs I prefer to use the extension .pl.

A typical shebang line for perl is: #!/usr/bin/perl

To let the server know it is a cgi program, the files are generally placed in a special directory on the server called /cgi-bin. For security reasons the webserver does not allow chmod permission settings of 777 or 775 for scripts. I set them to 755.

I use the following reference test perl file to check the correct configuration of my hosted webserver.

#!/usr/bin/perl -w

use strict;
use CGI::Carp qw(fatalsToBrowser);

my $headline = “Perl Reference Script”;

print “Content-type: text/htmlnn”;
print ‘<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>’, “n”;
print “<html><head><title>Perl Test</title></head><body>n”;
print “<h1>$headline</h1>n”;
print “<p>This test script opens a data.txt file, appends a name to it and creates a new file new.txt</p>n”;
print “</body></html>n”;

open (MYFILE, ‘data.txt’) || die “Could not open file data.txt”;;
while (<MYFILE>) {
chomp;
print “$_n”;
}
close (MYFILE);

open (MYFILE, ‘>>data.txt’) || die “Could not write to file data.txt”;;
print MYFILE “Bobn”;
close (MYFILE);

open (MYFILE, ‘>new.txt’) || die “Could not create file new.txt”;
print MYFILE “This file has been createdn”;
close (MYFILE);

The following commands are used to run the program:

  • -w : switch to turning on warnings
  • use strict : pragma for the interpreter to make it harder to write bad software
  • use CGI::Carp qw(fatalsToBrowser) : command to redirect fatal errors such as compiler or other errors to the browser
  • MYFILE : filehandler

A testfile to show my webserver cgi environment variables is available at the following link.  An advanced testfile can be started here. The access is protected with .htaccess and .htpasswd.

Processing and Eclipse

Last update : January 21, 2014

Processing is an open source programming language and environment for people who want to program images, animation, and interactions. It is used by students, artists, designers, researchers, and hobbyists for learning, prototyping, and production.

Processing is an open project initiated by Ben Fry and Casey Reas. It evolved from ideas explored in the Aesthetics and Computation Group at the MIT Media Lab. Development of Processing began formally in the Spring of 2001, the first alpha release 0001 was used in August 2001, the version 1.0 was released on 24th November 2008, a few days after the last beta version (release 157). Version 2 was released on September 5, 2013. The current version is 2.1 launched on October 27, 2013.

Processing programs can be easely exported to run on the web as Jas applications to run on Windows, Linux, Mac OS X or Android, as Java applets / Java projects or as Javascript web projects. Processing scripts are called sketches. Sometimes it might be useful to combine a Processing sketch with a general Java project, which is best done in Eclipse.

A tutorial how to use Processing in Eclipse is available on the Processing website. The following code has been saved as file MyEclipseSketch.java and runs succesfully as applet in Eclipse.

import processing.core.*;
public class MyFirstSketch extends PApplet{

public void setup() {
size (400,400);
background(0);
}
public void draw() {
stroke (255);
if (mousePressed) {
line (mouseX,mouseY,pmouseX,pmouseY);
}
}
}

To embed the applet in a webpage, the generated MyEclipseSketch.class file was added to the Processing archive core.jar and I renamed the archive file to eclipse_sketch.jar. The html code to display the applet is very easy :

<html>
<header>
</header>
<body>
<applet code=”MyEclipseSketch.class” archive=”eclipse_sketch.jar”/>
</body>
</html>

Ruby : langage de programmation libre

Ruby est un langage de programmation libre. Il est interprété, orienté objet, et multi-paradigme. Le nom Ruby n’est pas un acronyme mais un jeu de mots avec le langage informatique Perl.

Yukihiro Matsumoto (Matz) est le créateur de Ruby. Ne trouvant pas dans les langages de programmation déjà existants de quoi le satisfaire, il commença l’écriture en 1993 et publia une première version en 1995.

REST : Representational state transfer

Last Update : April 15, 2013

Representational state transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. The terms were introduced in 2000 in the doctoral dissertation of Roy T. Fielding, one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification.

REST strictly refers to a collection of network architecture principles which outline how resources are defined and addressed. The term is often used in a looser sense to describe any simple interface which transmits domain-specific data over HTTP without an additional messaging layer such as SOAP or session tracking via HTTP cookies. The difference between the uses of the term “REST” therefore causes some confusion in technical discussions.

Systems which follow Fielding’s REST principles are often referred to as “RESTful”.

The claimed benefits of REST are listed in the the free encyclopedia Wikipedia.

Additional informations about REST are available at the following links :

VOXEO hosting platform

Voxeo offers three main application platforms for free to developers: CallXML, CCXML, and VoiceXML.

The Prophecy 8.0 – CallXML 3.0 platform allows developers to build robust IVR applications using only static content. CallXML suits the needs of most telephony applications that use touchtone input (DTMF).

The Prophecy 8.0 – CCXML W3C 1.0 platform allows to deploy the next-generation conferencing/call routing applications to ensure that they will stand the test of time.

The Prophecy 8.0 – VoiceXML 2.1platform includes the Voxeo ASR engine (available only in US English) and is the world’s first and only 100% certified-compliant VoiceXML 2.0 browser. The Prophecy Platform supports all the VoiceXML 2.1 additions and enhancements, as well as the SISR/SRGS grammar formatting standards. It also includes legacy support for the older GSL and JSGF grammar formats.

I created an account a few years ago to do my first trials with VoiceXML. Today I updated the account and started with a new HelloWorld test application. The telephone numbers to access the application are the following:

  • Skype VoIP :  +99000936 9991425592
  • SIP VoIP :  sip:9991425592@sip.voxeo.net
  • iNum Number : +883510001801392

iNum Number from Luxembourg : +352 20880108 p 883510001801392

If calling from a mobile phone (for instance with a BlackBerry) to an iNum number, you have to insert a pause between the local number and the iNum number by using the menu during the number editing.

My first iNum call to the HelloWorld application was succesfully established today at 21h21 with my mobile phone.

iNum : a global phone number of the ITU (+883)

An iNum is a new kind of global phone number that is not tied to any country or location. It uses a new +883 global country code that was recently created by the ITU (International Telecommunication Union). An iNum offers several compelling advantages:

  • It is a global phone number that will be able to be called from anywhere in the world
  • It is a portable phone number in that it is not tied to a specific country
  • Calls to an iNum can be free from some service providers and may be inexpensive from other providers
  • It is reachable from both the traditional Public Switched Telephone Network (PSTN) and also from Voice-over-IP (VoIP) providers

The +883 country code used for iNums is still in the process of being deployed globally across the existing PSTN. As a result, users in some countries may not be able to dial an iNum directly on their existing PSTN carrier. To assist users whose carriers do not yet support the +883 country code, Voxbone, the carrier behind the iNum initiative, has set up local phone numbers in 45 countries. For Luxembourg, this number is +352 20880108. Simply dial this local access number and dial the chosen iNum afterwards.

iNum is an initiative launched by Voxbone, supplier of local telephone numbers to communications services providers and businesses worldwide. Voxbone is a privately held company with offices in Brussels, Singapore and Los Angeles.

An iNum will be automatically assigned to developers of a new application on the free VoiceXML VOXEO platform.

ECLIPSE – an open development platform

Last update : June 29, 2015

Eclipse is an open source community whose projects are focused on building an open development platform comprised of extensible frameworks, tools and runtimes for building, deploying and managing software across the lifecycle. A detailed overview about the Eclipse software is available at Wikipedia.

I started a year ago to use the EUROPA version (platform 3.3) of Eclipse to develop JAVA applications for the web. I changed  later to the  release GANYMEDE (plaform 3.4.) published in june 25th, 2008. I used the IDE for Java EE Developers (163 MB) with tools for Java developers creating JEE and Web applications.

A tutorial how to create servlets with Eclipse has been published on the Java Tips website. A french tutorial about servlets and jsp pages with Eclipse and Tomcat is available at the website of Serge Tahé (Maître de conférences en Informatique à l’université d’Angers). Another useful tutorial about Struts (méthode de développement gérée par l’Apache Software Foundation qui a pour but de fournir un cadre standard de développement d’applications web en Java respectant l’architecture dite MVC : Modèle – Vue – Contrôleur ) has been edited by the same author.

Other interesting tutorials are listed below :

To integrate my existing Java projects in Eclipse, I created a new Java Project in the Eclipse Workspace, copied the folder with the source files in this new project folder and executed the file – refresh menu.

The Eclipse platform is also used for Android developments, a preconfigured ECLIPSE version is included in the Google Android SDK.

In the context of the OFUR project, I installed in late June 2015 the new Eclipse Mars version (4.5) with the Javascript Development Tools (from the Web, XML, JavaEE and OSGi section), the Eclipse Web Developer Tools and the jshint Tools.

I added my signature files ida_dsa and ida_rsa to the SSH2 settings in the Eclipse – Window – Preferences – General -Network Connections – SSH2 menu. I accepted the default location for the workspace (users/mbarnig/workspace) and for the local GIT repository (users/mbarnig/git) in the Eclipse – Window – Preferences – Team – Git menu.

To checkout the original code for the DICOM Web Viewer (DWV),  I entered the HTTPS clone URL of the DWV Github front page to the Git Repository in the Eclipse – Window – Show View – Others – Git menu, clicked the Clone a Git Repository action and selected the master branch to start the download of the source code.

The DWV tree was loaded into the local DWV repository. In the root source folder the file eclipse.epf (Eclipse Process Framework Project) produces a customizable software process enginering framework. I imported the .epf file with the menu File – Import – General – Preferences.

FileZilla, the free FTP Solution

Last update : November 21, 2014

On dezember 28th, 2008, I installed the version 3.1.6. of FileZilla, the free FTP solution. I used the preceding version succesfully for several months.

FileZilla is open source software distributed free of charge under the terms of the GNU General Public License. Both a client and a server are available. It supports FTP, SFTP, and FTPS (FTP over SSL/TLS). The client is available under many platforms, binaries for Windows, Linux and Mac OS X are provided.

My latest installed version is 3.9.0.6,  released October 20, 2014.

EC2 : Amazon Elastic Compute Cloud

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale computing easier for developers.

Amazon EC2 reduces the time required to obtain and boot new server instances to minutes, allowing to quickly scale capacity, both up and down, as the computing requirements change. Amazon EC2 provides developers the tools to build failure resilient applications and isolate themselves from common failure scenarios.

Amazon EC2 presents a true virtual computing environment, allowing you to use web service interfaces to launch instances with a variety of operating systems, load them with your custom application environment, manage your network’s access permissions, and run your image using as many or few systems as you desire.

To use Amazon EC2, an Amazon Machine Image (AMI) containing the applications, libraries, data and associated configuration settings is created or a pre-configured and templated image is used to get up and running immediately. The AMI is loaded into Amazon S3.

Amazon EC2 is elastic (scalable), flexible, completely controlled, designed for use with other Amazon Web Services, reliable, featured for Building Failure Resilient Applications (Amazon Elastic Block Store, Multiple Locations, Elastic IP Addresses), secure, inexpensive.

The default instance is a 32-bit platform with 1.7 GB of memory, 1 compute unit and 160 GB of instance storage (small instance). Large, extra-large and high-CPU instances are available for compute-intensive applications.Price:

The price for using a small instance is $0.10 per instance hour for Linux and $0.125 per instance hour for Windows. Amazon EC2 uses a variety of measures to provide each instance with a consistent and predictable amount of CPU capacity. Understanding the EC2 price model is not easy and several questions in the AWS forum refer to this issue. Here are some answers :

If you start an instance once every 24 hours and run it for less than an hour, and do this every day for a 30-day month, you will be charged for 30 instance hours.  As long as your instance is running, it is billable at the rate for that instance. A website would not be publicly available if the instance is not running. To run a website available 24/7 in a month, it will cost about $90 for windows instance-hours + storage charge + data in/out charge + others.

One customer confirmed the price calculation and stated that he compared AWS pricing with that of other companies. Although there were several companies that offered hosting for cheaper, in the end he decided to start using EC2 for the following reasons :

Although those sites were cheaper, none of them gave him as much flexibility as he wanted. He had to use their preset hosting configurations, which wasn’t very condusive towards hiswebsite-model. Similar cloud offerings, such as the ones offered by RackSpace, actually ended up being more expensive in the end. But most importantly, he could take advantage of Amazon’s other web services as well.  The one he was most excited about is Amazon Cloudfront to get a full-fledged content delivery service in one easy-to-use package.  Thats one offering that those “$9.99 a month!” companies can’t offer, and it’s something he needs.

There are other providers offering elastic computing power :

Protection des oeuvres littéraires et artistiques

La Convention de Berne pour la protection des oeuvres littéraires et artistiques permet aux artistes de bénéficier d’une protection légale dans les 164 pays signataires.

Le site Copyright-France constitue un dépôt de Copyright sûr, rapide, simple et économique qui a été choisi par des dizaines de milliers d’entreprises, de particuliers, d’administrations et de juristes.

Le Guide pratique du droit d’auteur d’Anne-Laure Stérin informe comment utiliser en toute légalité des textes, photos, films, musiques, Internet et comment protéger ses créations. Le livre publié par Editions Maxima, 2007 (ISBN 284001405X, 9782840014058) comporte 537 pages, des extraits sont visibles sur le site Google : recherche de livres.

Un guide très utile sur le droit d’auteur sur Internet est accessible sur le site de la cité scolaire Pierre Larousse de Toucy dans l’Yonne. Les règles de base à connaître et à respecter lorqu’on utilise un document sur Internet :

  • Citer le nom de son auteur et les références de l’oeuvre.
  • Respecter l’oeuvre, ne pas déformer la pensée de l’auteur, ne pas modifier l’oeuvre.
  • Si l’auteur est vivant ou s’il est décédé depuis moins de 70 ans, il faut demander son
  • accord écrit ou celui de ses “ayants droit » (famille, éditeur…).
  • Ne pas utiliser l’image d’une personne sans son autorisation.

On peut reproduire librement une œuvre si l’artiste est décédé depuis plus de 70 ans en citant l’auteur et la référence de l’œuvre ; dans le cas contraire il faut demander l’autorisation à l’artiste ou à ses ayants droit. Dans tous les cas il faut obtenir l’autorisation du propriétaire de l’œuvre. On doit toujours respecter l’intégralité de l’œuvre. Pour reproduire une photographie d’une œuvre, il faut également obtenir l’autorisation du photographe ou de l’agence qui le représente.

Une bande dessinée au sujet du droit d’auteur a été publié dans le cadre de l’accord entre l’Institut national pour la défense de la concurrence et la protection de la propriété intellectuelle (INDECOPI) et l’Organisation Mondiale de la Propriété Intellectuelle (OMPI) en 2001.