|
|
SMS Server Tools 3 Community |
Welcome, Guest. The forum is currently read-only, but will open soon. |
Fri Aug 29, 2025 21:26 |
Page: 1
Keywords: Mode: All keywords (AND) |
Wed Nov 03, 2010 08:27
|
Hiisi: OK, I saw that script but forgot about it before starting to write my own. After a bit of modification it serves my needs pretty well. At least it works. Thanks goes to edo and as usual to keke. Kiitos, Keijo!
|
Tue Nov 02, 2010 07:48
|
Hiisi: Operating system name and version: Fedora 12
Version of smsd: smstools-3.1.8-1.fc14.i686
Smsd installed from: package repository (test repository for F14)
Name and model of a modem: Huawei Technologies Co., Ltd. E620 USB Modem
Interface: USB
Hi! I'm writing a script that will handle incoming mail and place it in smstools outgoing directory (lets call it email2sms). The purpose of this script is correct handling of russian characters in sms. Namely, I would like to write messages in russian more than 70 characters long. The second problem is different encoding of incoming mail. I.e. some messages are in utf-8, others are in koi8-r. This script should take care of it. So, here it is:
#!/bin/bash
OUTFILE1=$(mktemp /tmp/letter.XXXXXX)
OUTFILE2=$(mktemp /tmp/body.XXXXXX)
cat >$OUTFILE1
from=$(grep "Content-Type: text/plain; charset=" $OUTFILE1 | sed 's/Content-Type: text\/plain; charset=//g')
cat $OUTFILE1 | iconv -f $from -t UTF-8 | sed '1,/^$/ d' | sed '/^$/d' > $OUTFILE2
# the above lines extract body of incoming email and recode it to utf-8
destination=$(whoami)
# username is <phone_number>@<host>
TEXT=$(cat $OUTFILE2)
ALPHABET=""
if ! echo -n "$TEXT" | iconv -t ISO-8859-15 >/dev/null 2>&1; then
ALPHABET="Alphabet: UCS"
fi
#if we can convert text to iso-8859, then no problem
smsd_user="smsd"
owner=""
if [ -f /etc/passwd ]; then
if grep $smsd_user: /etc/passwd >/dev/null; then
owner=$smsd_user
fi
fi
# the above is from keke' universal script; probably I don't need this construction
TMPFILE=`mktemp /tmp/smsd_XXXXXX`
echo "To: $destination" >> $TMPFILE
[ -n "$ALPHABET" ] && echo "$ALPHABET" >> $TMPFILE
echo "" >> $TMPFILE
if [ -z "$ALPHABET" ]; then
echo -n "$TEXT" >> $TMPFILE
else
echo -n "$TEXT" | iconv -t UNICODEBIG >> $TMPFILE
fi
if [ "x$owner" != x ]; then
chown $owner $TMPFILE
fi
FILE=`mktemp /var/spool/sms/outgoing/send_XXXXXX`
mv $TMPFILE $FILE
I know, it looks now as a promising nomination for silly scripting award. So any help is appreciated (hints, thoughts, etc.). Currently it doesn't work partially. When incoming mail is written in latin letters only the script places correct file in outgoing directory. However if the mail is writen in russian, then there's an error in procmail log:
procmail: Executing "/usr/local/bin/email2sms2"
iconv: illegal input sequence at position 0
chown: changing ownership of `/tmp/smsd_zR2eMp': Operation not permitted
And the resulting file in outgoing directory looks as follows:
To: 79057923509
Alphabet: UCS
See, there's empty line in the place where message text should be. And Alphabet shouldn't be UCS for this message.
The mentioned above iconv-error from log can be produced in terminal window. Here's an example:
echo $TEXT
русский текст
echo $TEXT | iconv -t ISO-8859-15
iconv: virheellinen syötesarja kohdassa 0
My local is UTF-8:
echo $LANG
fi_FI.UTF-8
Encoding of tmp file ($OUTFILE1) in the script is:
Universal transformation format 8 bits; UTF-8
So, why it all doesn't work I don't know. However I'm able to send message manually, using the script keke provided in this post.
Any thoughts?
|
Sun Oct 31, 2010 12:36
|
Hiisi:
...your MySQL installation probably is broken and re-installation is required.
Perkele! What a windoze approach it is!
Have you tried the eventhandler with root account for MySQL?
Yep, I did. It works flawlessly.
With a quick view I cannot see what is causing the failure :(
Anyway, thanks for the help keke! Your replies are quick and meaningful and your software rocks!
|
Thu Oct 28, 2010 13:33
|
Hiisi: Forgot to mention that user smsd is created and granted all necessary permissions onto smsd DB.
|
Thu Oct 28, 2010 13:28
|
Hiisi: Operating system name and version: Fedora 12
Version of smsd: smstools-3.1.3-7.fc12.i686
Smsd installed from: package repository
Name and model of a modem / phone: Huawei Technologies Co., Ltd. E620 USB Modem
Interface: USB
Hi!
I'm trying to use mysmsd script to store all events in a MySQL database. I created the following script (as keke suggested in this post):
cat mysmsd
#!/bin/bash
# This is an example script that logs all events into an SQL database
# You need a MYSQL database as described in the documentation.
# Please read the documentation before using this script.
SQL_HOST=localhost
SQL_USER="smsd"
SQL_PASSWORD="<super_secret_passwd>"
SQL_DATABASE=smsd
SQL_TABLE=sms_log
DATE=`date +"%Y-%m-%d %H:%M:%S"`
#Extract data from the SMS file
FROM=`formail -zx From: < $2 | sed 's/"//g'`
TO=`formail -zx To: < $2`
#Remove plus sign, spaces, minus and short number prefix
TO=`echo "$TO" | sed 's/ //g' | sed 's/+//g' | sed 's/s//g' | sed 's/-//g'`
SUBJECT=`formail -zx Subject: < $2`
SENT=`formail -zx Sent: < $2`
TEXT=`sed -e '1,/^$/ d' < $2`
TEXTSQL=$(echo "$TEXT" | sed 's/\\/\\\\/g' | sed 's/\"/\\\"/g')
#Set some SQL parameters
if [ "$SQL_PASSWORD" != "" ]; then
SQL_ARGS="-p$SQL_PASSWORD";
else
SQL_ARGS="";
fi
SQL_ARGS="-h $SQL_HOST -u $SQL_USER $SQL_ARGS -D $SQL_DATABASE -s -e"
#Insert a new entry into the SQL table
if [ "$1" = "FAILED" ] || [ "$1" = "SENT" ]; then
mysql $SQL_ARGS "insert into $SQL_TABLE (type,sent,sender,receiver,msgid,text) values (\"$1\",\"$DATE\",\"$FROM\",\"$TO\",\"$3\",\"$TEXTSQL\");";
elif [ "$1" = "RECEIVED" ]; then
mysql $SQL_ARGS "insert into $SQL_TABLE (type,sent,received,sender,receiver,text) values (\"RECEIVED\",\"$SENT\",\"$DATE\",\"$FROM\",\"$SUBJECT\",\"$TEXTSQL\");";
elif [ "$1" = "REPORT" ]; then
#Extract more data from the status report file
DISCHARGE=`sed -e 1,/SMS\ STATUS/d < $2 | formail -zx Discharge_timestamp:`
MSGID=`sed -e 1,/SMS\ STATUS/d < $2 | formail -zx Message_id:`
STATUS=`sed -e 1,/SMS\ STATUS/d < $2 | formail -zx Status: | cut -f1 -d,`
if [ "$MSGID" != "" ]; then
ID=`mysql $SQL_ARGS "select id from $SQL_TABLE where receiver=\"$FROM\" and type=\"SENT\" and msgid=\"$MSGID\" order by id desc limit 1;"`
mysql $SQL_ARGS "update $SQL_TABLE set received=\"$DISCHARGE\",status=\"$STATUS\" where id=\"$ID\";"
fi
fi
I made it executable:
-rwxr-xr-x. 1 root root 1948 28.10. 17:12 mysmsd
And added eventhandler to /etc/smsd.conf:
devices = GSM1
logfile = /var/spool/sms/smsd.log
infofile = /var/run/smsd/smsd.running
pidfile = /var/run/smsd/smsd.pid
loglevel = 5
checkhandler = /var/spool/sms/ucsautoconvert
eventhandler = /usr/local/bin/mysmsd
outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
failed = /var/spool/sms/failed
incoming = /var/spool/sms/incoming
sent = /var/spool/sms/sent
whitelist = /var/spool/sms/whitelist
[GSM1]
device = /dev/ttyUSB0
incoming = yes
report = yes
However it doesn't work as expected :'(
It saves nothing into the database and when I try to run it manually it responds with this message:
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'smsd'
What's wrong with it? Or is it just me?
TIA
|
Mon Jul 26, 2010 13:12
|
Hiisi: I have added the following rule:
KERNEL=="ttyUSB*", ATTRS{idVendor}=="1d6b", ATTRS{idProduct}=="0002", SYMLINK="modem", OWNER="smsd", GROUP="dialout", MODE="0660"
And now smsd starts perfectly. It works as expected until strange thing occurs: modem disconnects by itself. Here's dmesg' output:
option: option_instat_callback: error -108
option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
option 1-4:1.0: device disconnected
option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
option 1-4:1.1: device disconnected
option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2
option 1-4:1.2: device disconnected
usb 1-4: new high speed USB device using ehci_hcd and address 41
hub 1-0:1.0: unable to enumerate USB device on port 4
usb 3-2: new full speed USB device using ohci_hcd and address 14
usb 3-2: not running at top speed; connect to a high speed hub
usb 3-2: New USB device found, idVendor=12d1, idProduct=1001
usb 3-2: New USB device strings: Mfr=2, Product=1, SerialNumber=0
usb 3-2: Product: HUAWEI Mobile
usb 3-2: Manufacturer: HUAWEI Technology
usb 3-2: configuration #1 chosen from 1 choice
option 3-2:1.0: GSM modem (1-port) converter detected
usb 3-2: GSM modem (1-port) converter now attached to ttyUSB0
option 3-2:1.1: GSM modem (1-port) converter detected
usb 3-2: GSM modem (1-port) converter now attached to ttyUSB1
option 3-2:1.2: GSM modem (1-port) converter detected
usb 3-2: GSM modem (1-port) converter now attached to ttyUSB2
In some other thread I saw you told the OS causes this. So, I have asked this question on Fedora' mailing list. Hope will get support there soon.
As for the problem with warnings about suspicious .procmailrc fail, I've found solution to it. it was wrong test' user home directory permissions that caused this. I had to make sure it's writeable only by user itself (and not by its group).
Anyway, thanks for fast and useful support, Keijo. Appreciate that!
|
Mon Jul 26, 2010 08:10
|
Hiisi: Forgot to mention that smssend doesn't work with /dev/modem in /etc/smsd.conf, even running as root. I have a lot of entries like this in smsd' logfile:
2010-07-26 12:14:46,3, GSM1: Could not send character A, cause: Invalid argument
2010-07-26 12:14:56,3, GSM1: Could not send character ., cause: Invalid argument
Everything works as expected when using /dev/ttyUSB0 in config file.
|
Mon Jul 26, 2010 08:01
|
Hiisi:
I have to say that I do not know what causes the trouble in your server.
In my server the file .procmailrc is -rw-r--r-- and owned by user:user. Email2sms works as expected. If you changed permissions to 0640, you could try once more with 0644.
As I do not know how to fix this issue, you could try to find a solution with Google, search something like "procmail Suspicious rcfile .procmailrc". It seems that this is a common problem.
Now I have:
# ls -l /home/test/.procmailrc
-rw-r--r--. 1 test test 132 22.7. 15:41 /home/test/.procmailrc
But still having the same warnings in /var/log/maillog... :(
Perhaps Fedora package has changed something, I cannot check it right now because I have no FC installed. If that smssend is a script, does it place files into /var/spool/sms/outgoing directory?
Yes, it does.
First stop the smsd if it's running. Then check if a device is symbolic link:
# ls -l /dev/ttyUSB0
lr-xr-xr-x 1 root root 9 Jul 5 14:40 /dev/ttyUSB0 -> usb/tts/0
In my case it's a link. Check if any process is using that device:
# lsof | grep usb/tts/0
smsd 31409 root 6u CHR 188,0 827 /dev/usb/tts/0
In my case smsd is using it, because I did not stop it. You should not see any processes.
Thanks for the hint. No other process is using it.
Use one port only, because those are interfaces to the same device. In some cases only a certain port was working with AT commands. When in your case any port is working, just select single one.
If possible and necessary, use udev to keep the names of ports the same.
I have created the following udev rule:
# cat /etc/udev/rules.d/95-huawei-e15150.rules
SUBSYSTEM=="usb", ATTRS{serial}=="0000:00:03.3", SYMLINK+="modem" GROUP="dialout"
Now when I plug in the device /dev/modem file appears but ownership is wrong:
# ls -l /dev/modem
lrwxrwxrwx. 1 root root 15 26.7. 11:45 /dev/modem -> bus/usb/001/015
I can't understand why GROUP option doesn't work as expected. The bus /dev/modem refer to has right permissions:
# ls -l /dev/bus/usb/001/015
crw-rw-r--. 1 root dialout 189, 14 26.7. 11:45 /dev/bus/usb/001/015
|
Sun Jul 25, 2010 11:04
|
Hiisi:
Now I see in /var/log/maillog:
Jul 22 16:01:31 kello procmail[15242]: Suspicious rcfile "/home/test/.procmailrc"
Try this:
# chmod 0640 /home/test/.procmailrc
Also check who owns the file, and change it if it's not owned by user test. And check that /home/test is owned by test:test.
Done that. It has been owned by root. But still having the same warnings in /var/log/maillog
smssend? It's not a program from Smstools. Probably you have another SMS daemon running.
[Sampo@kello ~]$ yum provides /usr/bin/smssend
Ladatut liitännäiset: fastestmirror, presto, refresh-packagekit, show-leaves
smstools-3.1.3-7.fc12.i686 : Tools to send and receive short messages through
: GSM modems or mobile phones
Asennuslähde: fedora
Vastaavuus :
Tiedostonimi: /usr/bin/smssend
smstools-3.1.3-7.fc12.i686 : Tools to send and receive short messages through
: GSM modems or mobile phones
Asennuslähde: installed
Vastaavuus :
Muuta : Tarjoajavastaavuus: /usr/bin/smssend
It may also cause that "Input/output error", which means that the device is not usable. Check if another process is using your modem, and try to stop it.
Sorry, I don't know how to do that :'(
Also check what ports were provided when you plugged your modem (using dmesg), and if there is more than one port, try with another one.
From dmesg output:
usb 1-4: new high speed USB device using ehci_hcd and address 118
usb 1-4: New USB device found, idVendor=12d1, idProduct=1001
usb 1-4: New USB device strings: Mfr=2, Product=1, SerialNumber=0
usb 1-4: Product: HUAWEI Mobile
usb 1-4: Manufacturer: HUAWEI Technology
usb 1-4: configuration #1 chosen from 1 choice
option 1-4:1.0: GSM modem (1-port) converter detected
usb 1-4: GSM modem (1-port) converter now attached to ttyUSB0
option 1-4:1.1: GSM modem (1-port) converter detected
usb 1-4: GSM modem (1-port) converter now attached to ttyUSB2
option 1-4:1.2: GSM modem (1-port) converter detected
usb 1-4: GSM modem (1-port) converter now attached to ttyUSB3
When I pug in this modem there's always 3 new devices:
/dev/ttyUSB0
/dev/ttyUSB1
/dev/ttyUSB2
or
/dev/ttyUSB1
/dev/ttyUSB2
/dev/ttyUSB3
Or sometimes (like in the output above):
/dev/ttyUSB0
/dev/ttyUSB2
/dev/ttyUSB3
It doesn't matter which one I use in /etc/smsd.conf. So, I've created 3 devices:
[root@kello ~]# cat /etc/smsd.conf
# Example smsd.conf. Read the manual for a description
devices = GSM1, GSM2, GSM3
logfile = /var/spool/sms/smsd.log
infofile = /var/run/smsd/smsd.running
pidfile = /var/run/smsd/smsd.pid
loglevel = 5
checkhandler = /var/spool/sms/ucsautoconvert
# Settings to run smsd without root priviledges:
user = Sampo
group = dialout
outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
failed = /var/spool/sms/failed
incoming = /var/spool/sms/incoming
sent = /var/spool/sms/sent
[GSM1]
device = /dev/ttyUSB0
incoming = yes
report = yes
#pin = 1111
[GSM2]
device = /dev/ttyUSB1
incoming = yes
report = yes
#pin = 1111
[GSM3]
device = /dev/ttyUSB2
incoming = yes
report = yes
#pin = 1111
It causes errors like this one:
2010-07-25 15:09:25,3, GSM3: Cannot open serial port /dev/ttyUSB2, error: No such file or directory
2010-07-25 15:09:25,2, GSM3: Modem handler 2 terminated.
But anyway, it works :D
Still can't find solution to my problem :(
Kiitos, keke.
|
Thu Jul 22, 2010 12:10
|
Hiisi: Operating system name and version: Linux kello.ru 2.6.32.16-141.fc12.i686 #1 SMP Wed Jul 7 04:47:25 UTC 2010 i686 i686 i386 GNU/Linux
Version of smsd: smstools-3.1.3-7.fc12.i686
Smsd installed from: package repository
Name and model of a modem: Huawei Technologies Co., Ltd. E620 USB Modem
Interface: USB
Dear all!
I'm trying to build email2sms gateway using fedora linux and Huawei USB-modem. The system runs sendmail with procmail to sort mail. I'm trying to use email2sms example script that was supplied with smstools. I have created user 'test' on this host (kello.ru). After I've created .procmailrc file in his home directory:
VERBOSE=off
MAILDIR=/var/spool/mail
DEFAULT=/var/spool/mail/test
LOGFILE=/var/log/procmail
:0
* ^TOtest
| /usr/local/bin/email2sms
Now I see in /var/log/maillog:
Jul 22 16:01:31 kello procmail[15242]: Suspicious rcfile "/home/test/.procmailrc"
I can send sms using smssend command. But no message arrives when I'm sending e-mail to test@kello.ru. No new files appears in /var/spool/sms/* Only this strange messages in smsd.logfile:
2010-07-22 16:10:35,3, GSM2: Could not send character A, cause: Input/output error
2010-07-22 16:10:45,3, GSM2: Could not send character ., cause: Input/output error
2010-07-22 16:10:55,3, GSM2: Could not send character A, cause: Input/output error
2010-07-22 16:11:05,3, GSM2: Could not send character ., cause: Input/output error
2010-07-22 16:11:15,3, GSM2: Could not send character A, cause: Input/output error
Could anybody point me to solution of this problem? Any help will be appreciated!
TIA
|
Page: 1
Time in this board is UTC.
|
|
|
 |
|
 |
|