21
21
<LINK REL="next" HREF="node256.html">
22
22
<LINK REL="previous" HREF="node254.html">
23
<LINK REL="up" HREF="node248.html">
23
<LINK REL="up" HREF="node249.html">
24
24
<LINK REL="next" HREF="node256.html">
29
29
<DIV CLASS="navigation"><!--Navigation Panel-->
30
<A NAME="tex2html3992"
30
<A NAME="tex2html3995"
31
31
HREF="node256.html">
32
32
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
33
33
SRC="/usr/share/latex2html/icons/next.png"></A>
34
<A NAME="tex2html3988"
34
<A NAME="tex2html3991"
36
36
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
37
37
SRC="/usr/share/latex2html/icons/up.png"></A>
38
<A NAME="tex2html3982"
38
<A NAME="tex2html3985"
39
39
HREF="node254.html">
40
40
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
41
41
SRC="/usr/share/latex2html/icons/prev.png"></A>
42
<A NAME="tex2html3990"
42
<A NAME="tex2html3993"
44
44
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
45
45
SRC="/usr/share/latex2html/icons/contents.png"></A>
47
<B> Next:</B> <A NAME="tex2html3993"
48
HREF="node256.html">File formats</A>
49
<B> Up:</B> <A NAME="tex2html3989"
50
HREF="node248.html">SMS</A>
51
<B> Previous:</B> <A NAME="tex2html3983"
52
HREF="node254.html">extensions.conf</A>
53
<B> <A NAME="tex2html3991"
47
<B> Next:</B> <A NAME="tex2html3996"
48
HREF="node256.html">Using smsq</A>
49
<B> Up:</B> <A NAME="tex2html3992"
50
HREF="node249.html">SMS</A>
51
<B> Previous:</B> <A NAME="tex2html3986"
52
HREF="node254.html">Sub address</A>
53
<B> <A NAME="tex2html3994"
54
54
HREF="node1.html">Contents</A></B>
57
57
<!--End of Navigation Panel-->
59
<H1><A NAME="SECTION001370000000000000000">
59
<H1><A NAME="SECTION001360000000000000000">
64
smsq is a simple helper application designed to make it easy to send
65
messages from a command line. it is intended to run on the Asterisk
66
box and have direct access to the queue directories for SMS and for
70
In its simplest form you can send an SMS by a command such as
71
smsq 0123456789 This is a test to 0123456789
72
This would create a queue file for a mobile originated TX message in
73
queue 0 to send the text "This is a test to 0123456789" to 0123456789.
74
It would then place a file in the /var/spool/asterisk/outgoing
75
directory to initiate a call to 17094009 (the default message centre
76
in smsq) attached to application SMS with argument of the queue name
80
Normally smsq will queue a message ready to send, and will then create
81
a file in the Asterisk outgoing directory causing Asterisk to actually
82
connect to the message centre or device and actually send the pending
86
Using <code>--process</code>, smsq can however be used on received queues to run a
87
command for each file (matching the queue if specified) with various
88
environment variables set based on the message (see below);
97
Specify a specific queue
98
In no specified, messages are queued under queue "0"
101
Specify destination address
104
Specify originating address
105
This also implies that we are generating a mobile terminated message
108
Specify the actual message
111
Specify a file to be read for the context of the message
112
A blank filename (e.g. --ud-file= on its own) means read stdin. Very
113
useful when using via ssh where command line parsing could mess up the
117
Mobile terminated message to be generated
119
Mobile originated message to be generated
126
Generate a message in the receive queue
128
Treat the file as UTF-8 encoded (default)
130
Treat the file as raw 8 bit UCS-1 data, not UTF-8 encoded
132
Treat the file as raw 16 bit bigendian USC-2 data
134
Specific a command to process for each file in the queue
135
Implies --rx and --mt if not otherwise specified.
136
Sets environment variables for every possible variable, and also ud,
137
ud8 (USC-1 hex), and ud16 (USC-2 hex) for each call. Removes files.
139
Specify the channel for motx calls
140
May contain X to use sub address based on queue name or may be full
142
Default is Local/1709400X
144
Specify the caller ID for motx calls
145
The default is the queue name without -X suffix
147
Wait time for motx call
150
Retry time for motx call
153
Retries for motx call
156
Specify the channel for mttx calls
157
Default is Local/ and the queue name without -X suffix
159
Specify the callerid for mttx calls
160
May include X to use sub address based on queue name or may be full
162
Default is 080058752X0
164
Wait time for mttx call
167
Retry time for mttx call
170
Retries for mttx call
172
--default-sub-address
173
The default sub address assumed (e.g. for X in CLI and dialled numbers
174
as above) when none added (-X) to queue
178
Create queue, but do not dial to send message
180
Do not wait if a call appears to be in progress
181
This could have a small window where a message is queued but not
182
sent, so regular calls to smsq should be done to pick up any missed
185
How many concurrent calls to allow (per queue), default 1
195
Specific hex string of user data header specified (not including the
197
May be a blank string to indicate header is included in the user data
198
already but user data header indication to be set.
200
Status report requested
202
Return path requested
204
Specify validity period (seconds)
206
Specify timestamp (YYYY-MM-DDTHH:MM:SS)
208
Spool dir (in which sms and outgoing are found)
209
Default /var/spool/asterisk
213
Other arguments starting '-' or '<code>--</code>' are invalid and will cause an
214
error. Any trailing arguments are processed as follows:-
219
<LI>If the message is mobile originating and no destination address
220
has been specified, then the first argument is assumed to be a
225
<LI>If the message is mobile terminating and no destination address
226
has been specified, then the first argument is assumed to be the
231
<LI>If there is no user data, or user data file specified, then any
232
following arguments are assumed to be the message, which are
237
<LI>If no user data is specified, then no message is sent. However,
238
unless <code>--no-dial</code> is specified, smsq checks for pending messages
239
and generates an outgoing anyway
244
Note that when smsq attempts to make a file in
245
/var/spool/asterisk/outgoing, it checks if there is already a call
246
queued for that queue. It will try several filenames, up to the
247
<code>--concurrent</code> setting. If these files exist, then this means Asterisk
248
is already queued to send all messages for that queue, and so Asterisk
249
should pick up the message just queued. However, this alone could
250
create a race condition, so if the files exist then smsq will wait up
251
to 3 seconds to confirm it still exists or if the queued messages have
252
been sent already. The <code>--no-wait</code> turns off this behaviour. Basically,
253
this means that if you have a lot of messages to send all at once,
254
Asterisk will not make unlimited concurrent calls to the same message
255
centre or device for the same queue. This is because it is generally
256
more efficient to make one call and send all of the messages one after
260
smsq can be used with no arguments, or with a queue name only, and it
261
will check for any pending messages and cause an outgoing if there are
262
any. It only sets up one outgoing call at a time based on the first
263
queued message it finds. A outgoing call will normally send all queued
264
messages for that queue. One way to use smsq would be to run with no
265
queue name (so any queue) every minute or every few seconds to send
266
pending message. This is not normally necessary unless <code>--no-dial</code> is
267
selected. Note that smsq does only check motx or mttx depending on the
268
options selected, so it would need to be called twice as a general
272
UTF-8 is used to parse command line arguments for user data, and is
273
the default when reading a file. If an invalid UTF-8 sequence is
274
found, it is treated as UCS-1 data (i.e, as is).
275
The <code>--process</code> option causes smsq to scan the specified queue (default
276
is mtrx) for messages (matching the queue specified, or any if queue
277
not specified) and run a command and delete the file. The command is
278
run with a number of environment variables set as follows. Note that
279
these are unset if not needed and not just taken from the calling
280
environment. This allows simple processing of incoming messages
283
Set if a queue specified
285
srr is set (to blank) if srr defined and has value 1.
287
rp is set (to blank) if rp defined and has value 1.
289
User data, UTF-8 encoding, including any control characters, but with
291
Useful for the content of emails, for example, as it includes any
294
User data, escaped UTF-8, including all characters, but control
295
characters \n, \r, \t, \f, \xxx and \ is escaped as \\
296
Useful guaranteed one line printable text, so useful in Subject lines
299
Hex UCS-1 coding of user data (2 hex digits per character)
300
Present only if all user data is in range U+0000 to U+00FF
302
Hex UCS-2 coding of user data (4 hex digits per character)
304
Other fields set using their field name, e.g. mr, pid, dcs, etc. udh
64
The following contexts are recommended.
70
; Mobile Terminated, RX. This is used when an incoming call from the SMS arrive
71
s, with the queue (called number and sub address) in ${EXTEN}
72
; Running an app after receipt of the text allows the app to find all messages
73
in the queue and handle them, e.g. email them.
74
; The app may be something like smsq --process=somecommand --queue=${EXTEN}
75
to run a command for each received message
78
exten = _X.,1, SMS(${EXTEN},a)
79
exten = _X.,2,System("someapptohandleincomingsms ${EXTEN}")
81
; Mobile originated, RX. This is receiving a message from a device, e.g.
82
; a Magic Messenger on a sip extension
83
; Running an app after receipt of the text allows the app to find all messages
84
; in the queue and handle then, e.g. sending them to the public SMSC
85
; The app may be something like smsq --process=somecommand --queue=${EXTEN}
86
; to run a command for each received message
87
; See below for example usage
89
exten = _X.,1, SMS(${EXTEN},sa)
90
exten = _X.,2,System("someapptohandlelocalsms ${EXTEN}")
92
</PRE><SMALL CLASS="SCRIPTSIZE"><B>
96
smsmtrx is normally accessed by an incoming call from the SMSC. In the
97
UK this call is from a CLI of 080058752X0 where X is the sub address.
98
As such a typical usage in the extensions.conf at the point of
99
handling an incoming call is:
103
exten = _X./8005875290,1,Goto(smsmtrx,${EXTEN},1)
104
exten = _X./_80058752[0-8]0,1,Goto(smsmtrx,${EXTEN}-${CALLERID(num):8:1},1)
105
</PRE><SMALL CLASS="SCRIPTSIZE"><B>
109
Alternatively, if you have the correct national prefix on incoming
110
CLI, e.g. using dahdi_hfc, you might use:
114
exten = _X./08005875290,1,Goto(smsmtrx,${EXTEN},1)
115
exten = _X./_080058752[0-8]0,1,Goto(smsmtrx,${EXTEN}-${CALLERID(num):9:1},1)
116
</PRE><SMALL CLASS="SCRIPTSIZE"><B>
120
smsmorx is normally accessed by a call from a local sip device
121
connected to a Magic Messenger. It could however by that you are
122
operating Asterisk as a message centre for calls from outside. Either
123
way, you look at the called number and goto smsmorx. In the UK, the
124
SMSC number that would be dialed is 1709400X where X is the caller sub
125
address. As such typical usage in extension.config at the point of
126
handling a call from a sip phone is:
130
exten = 17094009,1,Goto(smsmorx,${CALLERID(num)},1)
131
exten = _1709400[0-8],1,Goto(smsmorx,${CALLERID(num)}-{EXTEN:7:1},1)
132
</PRE><SMALL CLASS="SCRIPTSIZE"><B>
310
137
<DIV CLASS="navigation"><HR>
311
138
<!--Navigation Panel-->
312
<A NAME="tex2html3992"
139
<A NAME="tex2html3995"
313
140
HREF="node256.html">
314
141
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
315
142
SRC="/usr/share/latex2html/icons/next.png"></A>
316
<A NAME="tex2html3988"
143
<A NAME="tex2html3991"
318
145
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
319
146
SRC="/usr/share/latex2html/icons/up.png"></A>
320
<A NAME="tex2html3982"
147
<A NAME="tex2html3985"
321
148
HREF="node254.html">
322
149
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
323
150
SRC="/usr/share/latex2html/icons/prev.png"></A>
324
<A NAME="tex2html3990"
151
<A NAME="tex2html3993"
325
152
HREF="node1.html">
326
153
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
327
154
SRC="/usr/share/latex2html/icons/contents.png"></A>
329
<B> Next:</B> <A NAME="tex2html3993"
330
HREF="node256.html">File formats</A>
331
<B> Up:</B> <A NAME="tex2html3989"
332
HREF="node248.html">SMS</A>
333
<B> Previous:</B> <A NAME="tex2html3983"
334
HREF="node254.html">extensions.conf</A>
335
<B> <A NAME="tex2html3991"
156
<B> Next:</B> <A NAME="tex2html3996"
157
HREF="node256.html">Using smsq</A>
158
<B> Up:</B> <A NAME="tex2html3992"
159
HREF="node249.html">SMS</A>
160
<B> Previous:</B> <A NAME="tex2html3986"
161
HREF="node254.html">Sub address</A>
162
<B> <A NAME="tex2html3994"
336
163
HREF="node1.html">Contents</A></B> </DIV>
337
164
<!--End of Navigation Panel-->