1# --------------------------------------------------------------------
2# Using the GENERIC driver.
3# It is possible build simple client interfaces to dialin networks
4# for delivering SMS messages.
5#
6# A Simple generic script consists of three sections:
7#
8#	login
9#	send
10#	disconnect
11#
12#
13# Each sections is made up of a list of Actions.
14# Where each action is a dictionary consisting of
15# a number of entries, these include:
16#
17#	message
18#	send
19#	expect
20#	success
21#	failure
22#
23#
24# The basic sequence of events is:
25#
26#	1. If 'message' is present output to console.
27#	2. If 'send' is present output to server.
28#	3. If 'expect' is present, check the input from
29#	   the server against the expect string.
30#	4. If the expect string matches output 'success' to console.
31#	   proceed to next entry and goto step 1.
32#	5. If the expect string does NOT match, output 'failure' to
33#          console. do NOT proceed any further.
34#
35# --------------------------------------------------------------------
36#
37# Example.
38# The script below sends an email by connecting
39# to an SMTP server.
40#
41# --------------------------------------------------------------------
42
43{
44	login =
45	(
46		{	message = "Connecting to server...\n"
47		},
48		{
49			expect  = "220 "
50			success = "Welcome prompt found\n"
51			failure = "Welcome Failed - Welcome prompt expected\n"
52		},
53		{
54			expect  = "\n"
55			success = "Welcome prompt found\n"
56			failure = "Welcome Failed - Welcome prompt expected\n"
57		}
58	)
59
60	send =
61	(
62		{
63			send    = "MAIL FROM: bill.gates@microsoft.com\n"
64			expect  = "250 "
65			success = "Successfully set Mail from\n"
66			failure = "failed to set Mail from\n"
67		},
68		{
69			expect  = "\n"
70			success = ""
71			failure = ""
72		},
73		{
74			send    =
75			(
76				"RCPT TO: ",
77				'$ID$',
78				"\n"
79			)
80
81			expect  = "250 "
82			success = "Successfully set Mail to\n"
83			failure = "failed to set Mail to\n"
84		},
85		{
86			expect  = "\n"
87			success = ""
88			failure = ""
89		},
90		{
91			send    = "DATA\n"
92			expect  = "354 "
93			success = "Successfully initiating data transfer\n"
94			failure = "failed initiating data transfer\n"
95		},
96		{
97			expect  = "\n"
98			success = ""
99			failure = ""
100		},
101		{
102			send =
103			(
104				'$MSG$',
105				"\n",
106				".\n"
107			)
108
109			expect  = "250 "
110			success = "Successfully set data\n"
111			failure = "failed to set data\n"
112		},
113		{
114			expect  = "\n"
115			success = ""
116			failure = ""
117		}
118	)
119
120	disconnect =
121	(
122		{
123			send    = "QUIT\n"
124			expect  = "221"
125			success = "Disconnect successful\n"
126			failure = "Disconnect Failed\n"
127		},
128		{
129			expect  = "\n"
130			success = ""
131			failure = ""
132		}
133	)
134}
135