• No results found

Implementation Decisions

The Web2Sh framework targets the Web as its platform. Its use should not be limited to a certain Web browser or device. This means that the user interface needs to be generic in order to be used over the majority of Web browsers and Web enabled devices. The development of the user interface utilises only known Web standard languages and technologies, which are supported on all modern Web browsers. These languages/technologies are:

• HyperText Markup Language (HTML) • JavaScript Language

• Cascading Style Sheets (CSS)

• Asynchronous JavaScript and XML (AJAX) technology

AJAX was a key enabling technology for the Web2Sh interface. It offers a set of JavaScript methods that are used on the client-side. With Ajax, Web pages can send data to, and retrieve data from, a server asynchronously without interfering with the display and behaviour of the existing page.

4.8 Summary

This chapter presented a description of the Web2Sh command line user interface. This is the client side component of the framework. A key feature of the user interface was to be generic and be usable over the majority of popular Web browsers. Hence, the development of the user interface utilises only known and popular supported languages and technologies such as HTML, JavaScript, CSS, and the AJAX technology. This enables the framework to be used without the limitation of using a specific Web browser or device.

The next chapter introduces the WSh scripting language that was created to support end users in creating and customising their own Web automation tools.

Chapter Five:

THE WSH SCRIPTING LANGUAGE

5.1 Introduction

With the rise of Web-based applications in general, the Web is becoming an ideal platform to develop applications that were previously accessible only as desktop applications. For instance, Web users can use applications, such as eyeOs18, which is an Open Source Platform (Web operating system and Web office) that resembles a desktop, but is actually in the cloud since the computing resources are delivered as a service over the Internet. The eyeOs system was licensed under the GNU Public License version 3 (GPL3); the latest version eyeOs 2.5 runs under The GNU Affero General Public License. It cleverly utilises PHP, JavaScript and Ajax technologies to present various desktop-like applications running on Web browsers. Google Web Applications such as Mail, Docs, Calendar, and Maps, are also very good examples of applications in the cloud

In today’s Web, end users are shifting from desktop-based to Web-based applications and from local hard drive storage to network storage via Web servers. This, in turn, introduces the need for a shell scripting language for the Web, which would provide an adequate end-user tool to accomplish routine tasks. The availability of a Web shell and a scripting language to be used for building various Web commands/tools would be very useful for end users, programmers, and Web masters. A similar model is implemented on UNIX platforms where various shells and tools are available for users, programmers, and system administrators to facilitate the automation of various tasks.

This chapter describes the proposed WSh language; a Web-based UNIX-like scripting language for automating Web browsing tasks and for connecting together many diverse services that are available on the Web. WSh allows users to build, customise, and share their own Web commands to automate the execution of the variety of tasks that they may need to accomplish. The WSh scripting language can

be considered as a step towards enabling end users to better automate and share their Web experiences.

The Web2Sh framework implements a thin client-computing model. This means that end users only need a Web browser in order to use, write, and run WSh scripts. The actual parsing and execution of the scripts is mostly handled by Web2Sh server. Web2Sh encompass the WSh scripting language. A significant advantage of the WSh scripting language is that it enables end users to customise and integrate Web commands in order to utilise many Web resources. For example, WSh facilitates the invocation of Web services functionality; a procedure that normally requires advanced programming skills.

Many scripting languages are used all over the Web; JavaScript, VBScript, and Perl are three examples of such scripting languages. These languages can also be used for other purposes, e.g. VBScript is widely used for writing macros in various Microsoft applications.

In UNIX, users can write scripts to be saved as a text file, called shell scripts. These scripts can be invoked by their names, just like built-in UNIX commands. Web2Sh follows a similar model where users can write scripts in WSh and save them on the Web server as Web commands. An important characteristic of WSh is that it utilises a similar pipeline approach to UNIX shells, which allows users to connect the output of a Web command to an input of another.

Some Web commands are able to accept different types of input, e.g. raw Text, HTML, or XML. In this case, the Web commands behave in a polymorphic manner. In other words, Web commands can alter their execution behaviour according to the MIME type of the piped resource. Users may choose to filter some resources to guarantee only certain parts of the resource are piped to the next Web command. For example, if an HTML page has a list of students’ ids, lab time and group, an HTML segment representing one student might resemble:

<tr>

<td> ID2802 </td> <td> 4-6pm </td>

<td class="purplegroup">Purple</td> </tr>

In this case, a user might prefer to strip all HTML tags and use a UNIX shell tool like grep to extract the piece of text that has a certain user’s data in it. For example:

fetch “url” | txt | unix.grep “ID2802” ;

This script should print all lines containing a match to the given pattern. All HTML tags are stripped out because of the use of the txt filter.

After reading a line of text from a Web2Sh command line, the WSh Parser breaks the text up into words (tokens), and then determines word boundaries if quotes were used. The resulting tokens go through a check that substitutes values for variables and parameters.

Web2Sh interprets the resulting words as commands trailed by their flags and arguments. Web commands are either built-in commands, which are directly executed within the shell, or calls to external tools or programs, in which case, Web2Sh redirects the Web command to the appropriate wrapper (e.g. the UNIX Tool wrapper) to handle the command.

The WSh scripting Language supports a standard suite of programming constructs, including variables, lists, arithmetic operations, strings, quoting, and pattern matching. For flexibility and ease of use, the WSh scripting language is designed to be case-insensitive, to avoid common case related errors that inexperienced end users may make. This is in contrast to other languages, which are case-sensitive and take a JavaScript similar approach, such as the Chickenfoot scripting language.

The following is an example that demonstrates the ease of use of WSh in comparison to Chickenfoot. For the following Chickenfoot script:

go("google.com") enter("Web 2.0")

click("google search")

links = find ("link in bold") links.count

The alternative script in WSh would be:

Google "Web 2.0" | getLinks –p1 | find –i “<[b|strong]>” | count;

The Web command getLinks will get all the links on the page returned by Google search, the -p flag indicates that links will be returned alongside their parent tags, the find command would search for any links that have the tag <b> or <Strong>. A word in the link or the whole link can be in bold. The -i flag indicates that find should match the pattern regardless of its case. The last command count would return the number of the links that matched the search criteria.