Jump to content

Recommended Posts

Am scris cu un an in urma un tutorial despre trimiterea sms-urilor din linia de comanda si vazand ca a mai cerut cineva pe aici informatii diverse despre gateway-uri sms, m-am gandit sa pun tutorialul si aici. Ideea este simpla, daca aveti un abonament sau cartela reincarcabila cu "oarece" optiuni pentru a trimite multe sms-uri, va puteti face propriul sms gateway.

Testul de mai jos l-am facut utilizand un modem huawei (am sa dau edit la post sa va spun modelul exact), iar intentia a fost de a face un sistem de monitorizare servere/servicii prin SMS+mail.

Am conectat modemul intr-un server local folosit pentru teste si monitorizare, apoi m-am conectat la el utilizand ‘cu‘. Am trimis un sms in acest fel, sa-mi aduc aminte de vremurile apuse cand foloseam modem-uri. Rezultatul se poate vedea in aceasta imagine.

Metoda a fost oarecum primitiva, asa ca am instalat ‘smstools’ din ‘/usr/ports/comms/smstools’.


hp ~ # make install clean -C /usr/ports/comms/smstools
hp ~ # echo 'smsd_enable="YES"' >> /etc/rc.conf
hp ~ # cat >> /usr/local/etc/smsd.conf << EOF

# file '/usr/local/etc/smsd.conf'
devices = GSM1
logfile = /var/log/smsd.log
loglevel = 7

[GSM1]
device = /dev/cuaU0.0
incoming = no
pin = 2653
rtscts = no
EOF

hp ~ # /usr/local/etc/rc.d/smsd start
hp ~ # ./smssend +4915223008abc 'read the fucking manual'
hp ~ # tail -f /var/log/smsd.log
2011-04-19 01:48:17,6, GSM1: Modem handler 0 has started.
2011-04-19 01:48:17,6, smsd: outgoing file checker has started.
2011-04-19 01:49:09,6, smsd: Moved file /var/spool/sms/outgoing/send_qoWmwT to /var/spool/sms/checked
2011-04-19 01:49:19,6, smsd: I have to send 1 short message for /var/spool/sms/checked/send_qoWmwT
2011-04-19 01:49:19,6, GSM1: Sending SMS from to 4915223008abc
.........................................
2011-04-19 01:49:34,5, GSM1: SMS sent, To: 4915223008abc
2011-04-19 01:49:34,6, smsd: Deleted file /var/spool/sms/checked/send_qoWmwT

Scriptul cu care am trimis sms-ul: (il puteti pune in ‘/usr/local/bin‘):


#!/bin/sh
# This script send a text sms at the command line by creating
# a sms file in the outgoing queue.
# I use it for testing.

# $1 is the destination phone number
# $2 is the message text
# if you leave $2 or both empty, the script will ask you

DEST=$1
TEXT=$2

if [ -z "$DEST" ]; then
printf "Destination: "
read DEST
fi

if [ -z "$TEXT" ]; then
printf "Text: "
read TEXT
fi

FILE=`mktemp /var/spool/sms/outgoing/send_XXXXXX`
chmod g+wr $FILE

echo "To: $DEST" >> $FILE
echo "" >> $FILE
echo -n "$TEXT" >> $FILE

Note:

- Daca aveti totul la indemana, in cateva ore va puteti face propriul gateway de sms-uri.

- Scriptul bash utilizat pentru trimiterea sms-urilor nu este facut de mine.

- Nu uitati sa schimbati pin-ul in smsd.conf.

- In cazul in care imprumutati acest tutorial pentru alte site-uri, va rog sa specificati sursa:

https://rstcenter.com/forum/54068-sms-gateway.rst

Edited by aelius
  • Like 1
  • Upvote 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...