Appendix 3. Script examples

These scripts can be found in co4/examples/basic/SCRIPTS. They can be invoked in any order. They trace (using CO4_TRACE) the communication between the various repositories involved in several windows. Some examples corresponds to the CO4 specification examples (they concern repositories containing numbers). The syntax for running a particular script is:

$ ./run-script ANSUrl SCRIPTS/name_of_script

where ANSUrl is the URL of the CO4 ANS, that must have been installed before.

Script syntax

The script syntax is very raw. It is given here only for inteligibility purposes and not as a scripting manual.

The first line of the script is relevant since it allows the system to compute the size that the X-terminal will occupy. Otherwise, whatever is placed after a sharp (#) is considered as a comment and not futher interpreted.

The script is interpreted line after line. Each line consists in three parts: the repository which is concerned by the line, the triggering message and the action. The repository is identified by its name. The triggering message is made of two part separated by a colon (:): the name of the repository which sent the message and the three first letters of the performatives. This message can be void identified by void fields (filled by underscores, _) in which case the action takes place immediatly. The action is specified by an identifier and arguments in a row.


The Mini script tests the registration of one base to another and closing of the connexion.

# 2 repositories
# this test shows the communication between 2 base"

B1  __:___     group 2  #B1 becomes group rep., with 2 as knowledge

B2  __:___     register B1
B2  B1:tel     eval 2

B2  B1:not     signal
B2  __:___     exit

B1  B2:sig     exit


The Error script shows various error messages in the protocol.

# 2 repositories
# this test shows the errors

B2  __:___    register B2
B1  __:___    register B4
B2  __:___    register --	# user doesn't exist
B2  __:___    register B1

B1  B2:reg    exit 
B2  B1:not    exit 


The Accept script carries on evaluation, submission and acceptation of knowledge to the consensual repository. The comments display

# 3 repositories

B1  __:___    group	124	# become THE group repository

B2  __:___    register B1		#
B2  B1:tel    apply 			# perform B1's content, given by the TELL 

B3  __:___     register B1		# 
# B1 -ask-all(register B3)--> B3
	B2  B1:ask     accept  	# B1 asks B2 -> B2 accept B3's registeration 
B1  B2:rep     print  		
B1  __:___     print  		# just to print 2 blank lines

B2  B1:pno     eval 154		# after pnotify, evaluate A=1
B1  B2:eva     print 

B2  B1:not     achieve 154
# B1 --(13/)ask-all(154)--> B2, B3
 	B3  B1:ask     accept
	B2  B1:ask     accept 
# B1 --pnotify(accept)-> B3, B2
# B1 --notify(accept)-> B2
# B1 --tell(154)-> B3, B2

B3  B1:tel    apply 

B3  __:__    exit
B2  B1:tel   signal
B2  __:___   exit

B1  B2:sig   sleep 
B1  __:__    exit 


The Forward_reg script tests the forward registration of a repository's repository to a third repository.

# 3 repositories

B1  __:___     group	124
B2  __:___     group   100

B3  __:___     register B2		# 
B3  B2:tel     print B3 registers to B2 

B3  __:___     forward register B1	# to have B2 registered to B1
# B2 --()ask-all(forward(register))--> B3
 	B3  B2:ask     accept   
# B2 --pnotify(accept)-> B3,
# B2 --notify(accept)-> B3

# B2 --register-> B1
#	B1 --notify(accept)-> B2
#	B1 --tell(124)-> B2
# 		B2 --ask-all(achieve(124))-> B3
B3  B2:ask  accept
# 		B2 --tell(124)-> B3
B3  B2:tel    signal
B3  __:___    exit

B2  B3:sig    exit
B1  B3:sig    exit 


The Mail script tests the ability of the system to work through shutdown of repository and take advantage of the mailbox system.

# 2 repositories
# this test shows the communication between B2 and B1 by theirs MBox."

B1  __:___    group 124	  #B1 becomes group rep., with 124 as knowledge

B2  __:___     register B1
B2  B1:tel     eval 3		# B1 is up, so the msg is sent to it.	

B1  B2:eva    signal		# as soon as B1 receives EVAL from B2, it signals
B1  __:___    shutdown		# its disconnection

B2  B1:sig    sleep 2		# give time to B1 for deconnection,
B2  __:___    eval 4		# B1 is down -> B2's request is sent to B1's mbox
B2  __:___    signal		# and B2 signals
B2  __:___    shutdown		# its deconnection

B1  B2:sig   print B1 wakes up
B1  __:___   sleep 5
B1  __:___   wakeup	# B1 reads it's MBOX,  answers to 'eval', but to B2's MBOX
B1  __:___   signal	# wakeup done.

B2  __:___   print initiatives  	# to see that 'eval' isn't answered yet
B2  __:___   print Wait for B1's reconnection 
B2  B1:sig   wakeup

B2  __:___    exit
B1  __:___    exit