SMS Server Tools 3
This site is hosted by Kekekasvi.com
 Menu
Basic information:
Additional information:
Support:
Get SMS Server Tools 3:
Additional Options

 Sponsored links

 Search
Custom Search

 Visitor locations
 
 SMS Server Tools 3 Community
Welcome, Guest. Please login or register. Thu Mar 28, 2024 18:24
SMSTools3 Community » Help and support Bottom

[answered] Mis-coding/Disorderly code

  This topic is locked

Page:  1

Author Post
Member
Registered:
May 2010
Location: sichuan chengdu, China
Operating system name and version: Linux version 2.6.24-19-generic,Ubuntu 4.2.3-2ubuntu7
Version of smsd: smstools3-3.1.8
Smsd installed from: sources
Name and model of a modem / phone: GSM MODEM
Interface: USB

Please excuse for my poor english. I am a common chinese coder.
The problem was that I send a short messge by using command "sendsms 8613708203321 '测试'".
when my phone received this message, I saw the content was Mis-coding/Disorderly code,like 'au@e'.

the smsd.conf was


Can you tell me what can I do. thanks

Member
Registered:
May 2010
Location: Russian Federation
sendsms is designed to work with 7bit ascii only.

you need something like this:
#!/bin/sh

FILE=`mktemp /tmp/smsd_XXXXXX`
DEST=$1
TEXT=$2

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

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

echo "To: $DEST" >> $FILE
echo "Alphabet: UCS" >> $FILE
echo "" >> $FILE
echo -n "$TEXT" | iconv -t ucs-2be >> $FILE

chmod 644 $FILE
mv $FILE  /var/spool/sms/outgoing/
'bash' Syntax Highlight powered by GeSHi


ps: sorry, i don't test this script ;)

Member
Registered:
May 2010
Location: sichuan chengdu, China
Topic owner
edo wrote
sendsms is designed to work with 7bit ascii only.

you need something like this:
#!/bin/sh

FILE=`mktemp /tmp/smsd_XXXXXX`
DEST=$1
TEXT=$2

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

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

echo "To: $DEST" >> $FILE
echo "Alphabet: UCS" >> $FILE
echo "" >> $FILE
echo -n "$TEXT" | iconv -t ucs-2be >> $FILE

chmod 644 $FILE
mv $FILE  /var/spool/sms/outgoing/
'bash' Syntax Highlight powered by GeSHi


ps: sorry, i don't test this script ;)

:oops:
I create a new file named out-convert.pl with your script. and edit the smsd.conf,add one line with 'checkhandler = /bin/smsd/out-convert.pl'.
when I execute the command with '/etc/init.d/sms3 start', I get the arguments $1,$2 is '/var/spool/sms/outgoing/send_B16223' and empty.

Member
Registered:
May 2010
Location: Russian Federation
it is not "checkhandler", but standalone script like original sendsms.

save this file as /usr/local/bin/sendsms-ucs and call "sendsms-ucs 8613708203321 '测试'"


« Last edit by edo on Mon May 31, 2010 08:47, 168 months ago. »
Member
Registered:
May 2010
Location: sichuan chengdu, China
Topic owner
It`s done. Thanks, edo.
And what can I do that I use checkhandler. how can I convert the outgoing files character set the text only.
If I use


It will failed. the error is 'No destination in file /var/spool/sms/outgoing/send_001'.
Thank you.

Member
Registered:
May 2010
Location: Russian Federation
you recode not only mesaage body, but all message including headers (like "To:").

Member
Registered:
May 2010
Location: sichuan chengdu, China
Topic owner
yes , but what can I recode the text part not all pary.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
See this post, it contains a sample checkhandler.

If you do the character set conversion in the sendsms-ucs script, you do not need a checkhandler. But you could modify the sendsms-ucs script: remove the iconv and write a header "Alphabet: UTF-8" to the file. Then that checkhandler will do the conversion. You can also create a message file with an editor, and the checkhandler will convert message to UCS if that header exists.

Member
Registered:
May 2010
Location: sichuan chengdu, China
Topic owner
Thank you keke . It works good.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
These changes will do the automatic detection of character set used, and makes the script sendsms compatible with Unicode:

echo "-- "
echo "Text: $TEXT"

ALPHABET=""
if which iconv > /dev/null 2>&1; then
 if ! $ECHO -n "$TEXT" | iconv -t ISO-8859-15 >/dev/null 2>&1; then
   ALPHABET="Alphabet: UCS"
 fi
fi


and:


 $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



Hopefully you can test it. The checkhandler is not required, but could be used with messages created with an editor.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Here is the complete script with changes:

#!/bin/bash
# This script send a text sms at the command line by creating
# a sms file in the outgoing queue.

# $1 is the destination phone number.
# $2 is the message text.
# If you leave $2 or both empty, the script will ask you.
# If you give more than 2 arguments, last is taken as a text and
# all other are taken as destination numbers.
# If a destination is asked, you can type multiple numbers
# delimited with spaces.

# Keys for example: "password" and "keke":
# KEYS="5f4dcc3b5aa765d61d8327deb882cf99 4a5ea11b030ec1cfbc8b9947fdf2c872 "

KEYS=""

# When creating keys, remember to use -n for echo:
# echo -n "key" | md5sum

smsd_user="smsd"

# Will need echo which accepts -n argument:
ECHO=echo
case `uname` in
  SunOS)
    ECHO=/usr/ucb/echo
    ;;
esac

if ! [ -z "$KEYS" ]; then
  printf "Key: "
  read KEY
  if [ -z "$KEY" ]; then
    echo "Key required, stopping."
    exit 1
  fi
  KEY=`$ECHO -n "$KEY" | md5sum | awk '{print $1;}'`
  if ! echo "$KEYS" | grep "$KEY" >/dev/null; then
    echo "Incorrect key, stopping."
    exit 1
  fi
fi

DEST=$1
TEXT=$2

if [ -z "$DEST" ]; then
  printf "Destination(s): "
  read DEST
  if [ -z "$DEST" ]; then
    echo "No destination, stopping."
    exit 1
  fi
fi

if [ -z "$TEXT" ]; then
  printf "Text: "
  read TEXT
  if [ -z "$TEXT" ]; then
    echo "No text, stopping."
    exit 1
  fi
fi

if [ $# -gt 2 ]; then
  n=$#
  while [ $n -gt 1 ]; do
    destinations="$destinations $1"
    shift
    n=`expr $n - 1`
  done
  TEXT=$1
else
  destinations=$DEST
fi

echo "-- "
echo "Text: $TEXT"

ALPHABET=""
if which iconv > /dev/null 2>&1; then
  if ! $ECHO -n "$TEXT" | iconv -t ISO-8859-15 >/dev/null 2>&1; then
    ALPHABET="Alphabet: UCS"
  fi
fi

owner=""
if [ -f /etc/passwd ]; then
  if grep $smsd_user: /etc/passwd >/dev/null; then
    owner=$smsd_user
  fi
fi

for destination in $destinations
do
  echo "To: $destination"

  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
done
 
 
'bash' Syntax Highlight powered by GeSHi


  This topic is locked

Page:  1

SMSTools3 Community » Help and support Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.