ASPL Manual v 1.00
© 2024 by SetSphere.COM


12-1

   ASPL Scripts by Examples

The ASPL interpreter provides a scripting language and it can parse, analyze, and execute ASPL scripts. However, how to get the shell to load the interpeter so that the later can execute the content of the script.

The env command is used on many systems to startup a computer script. The script name, an exceutable file also called program, follows the env command and the system initializes the system environment and exec the corresponding script.

The scripting language of an interpreter typically provides a mechanism to load a script through the environment of the UNIX system. This is typically done in two ways: either by invoking the interpreter following #! and these two characters happen to be the absolute first two characters in the content of the script name, or by invoking the env directly: that is by including env on the first line and by following it by the interpreter name.

In either case the script is loaded through the UNIX shell environment. The first case requires specifying the full path to the location of the interpreter, and may not work on some UNIX systems where the loading of the special (hashclamation) shebang #! has been disabled. The second case may seem simple, yet we need to give it special attention considering the many UNIX systems and the fact that env loading mechanism has not been addressed by POSIX (different vendors implement the env following their needs). Furthermore some vendors provide the -S option supposedly to be followed by a string to be split into the script name and its argument, but fail the split and present the whole string as it is: one long string that is assumed to be the interpreter name (hence failing once again if the string contain arguments). In addition, the location of the env command may vary between systems: the env program may be located in /usr/bin, or /bin, or somewhere else.

Since all UNIX vendors (at least) load what follows the env as a single string pointing to the interpreter named program, then it is possible to generalize a solution to the loading of the interpreter and its arguments.

To overcome the env loading issues and to make ASPL portable on different UNIX systems, ASPL uses a two-lines shebangs line: the first line is to read the interpreter name, and the second line is to pass the arguments of the program. Note that the script name is the program name itself and is implicitly passed by env as $0 shell variable.

This chapter shows some scripting examples that can be run by the ASPL interpreter. All scripts can be found in the shared folder where you have installed the ASPL interpreter.

■ List of Scripts

The following is a list of references for the scripts listed in this chapter:

Script dircompare.aspl see SECTION 12.2.1 [Script dircompare.aspl]

Script dirdiff.pl see SECTION 12.3.1 [Script dirdiff.pl]

Script dirchange-monitor.sh see SECTION 12.4.2 [Script dirchange-monitor.sh]

Script randomdice.aspl see SECTION 12.5.1 [Script randomdice.aspl]

Script mutant.aspl see SECTION 12.6.1 [Script mutant.aspl]

Script twospheres.aspl see SECTION 12.7.1 [Script twospheres.aspl]

Script polyclouds.aspl see SECTION 12.8.1 [Script polyclouds.aspl]

Script jarcompare.aspl see SECTION 12.9.1 [Script jarcompare.aspl]

Script jarcompare.pl see SECTION 12.10.1 [Script jarcompare.pl]

Script jarcomparelong.aspl see SECTION 12.11.1 [Script jarcomparelong.aspl]

Script jarsimilarity.pl see SECTION 12.12.1 [Script jarsimilarity.pl]

Script pathcompare.pl see SECTION 12.13.1 [Script pathcompare.pl]

Script pathcompare.aspl see SECTION 12.14.1 [Script pathcompare.aspl]

Script envcompare.pl see SECTION 12.15.1 [Script envcompare.pl]

Script reapenv.aspl see SECTION 12.16.1 [Script reapenv.aspl]

Script wasreaper.aspl see SECTION 12.17.1 [Script wasreaper.aspl]

Script progenv.aspl see SECTION 12.18.1 [Script progenv.aspl]

Script progenvshellscompare.aspl see SECTION 12.19.1 [Script progenvshellscompare.aspl]

Script reapenvpidcompare.aspl see SECTION 12.20.1 [Script reapenvpidcompare.aspl]

Script bay12mon.pl see SECTION 12.21.1 [Script bay12mon.pl]

 

● Script dircompare.aspl

This is script is used to show how to ..

Script dircompare.aspl see SECTION 12.2.1 [Script dircompare.aspl]

 

● Script pathcompare.pl

This is script is used to show how to ..

Script pathcompare.pl see SECTION 12.13.1 [Script pathcompare.pl]

 

■ Executing ASPL from other programming languages

Since it is possible to pipe STDIN to the ASPL interpreter, it is possible use ASPL with other programming languages. ASPL reads the STDIN first line and determines if it is a shebang giving priority to its arguments (overriding any argument should it be specified prior to the -STDIN pipe). The following scripts show to call ASPL from Perl script. We will consider three examples:
script name        description
---------------    --------------------------------------
pathcompare.pl     compares your PATH on different hosts, 
envcompare.pl      compares your ENV on different hosts,
jarcompare.pl      compares the similarities between multiple JAR archives.


 

● Script pathcompare.pl

Script pathcompare.pl see SECTION 12.13.1 [Script pathcompare.pl]

Use the Perl script pathcompare.pl to compare your PATH on different hosts in a cloud environment. This script can retrieve and turn the list of files found on remote host PATH into a dataset. You will use ASPL to compare the PATH of many hosts in a cloud environment.

 

● Script envcompare.pl

Use the Perl script envcompare.pl to compare the ENV on different hosts in a cloud environment. This script can retrieve and turn the list of environment variables on remote hosts into datasets. With ASPL you can compare the ENV of many hosts in a cloud environment.

 

● Script jarcompare.pl

Script jarcompare.pl see SECTION 12.10.1 [Script jarcompare.pl]

Use the Perl script jarcompare.pl to compare the content of JAR archive files. Classes or JAVA files that have the same names can be compared since ASPL comparison algorithm work on the element attributes (like the checksum attribute). ASPL set operators can display changes in JAR archives by treating and comparing their content as datasets.