SHELL脚本编码转换问题(关于在cygwin下如何使用perlfetion发送免费短信)

sh/bash/dash/ksh/zsh等Shell脚本
回复
d0nny
帖子: 2
注册时间: 2008-08-18 0:57

SHELL脚本编码转换问题(关于在cygwin下如何使用perlfetion发送免费短信)

#1

帖子 d0nny » 2010-05-27 21:59

使用的perl脚本来至于csksoft发送fetion,地址如下:
perlfetion.pl

在Ubuntu下编写了一个小脚本,存储手机号码和密码,实现别名发送。

代码: 全选

#/bin/bash
NUM="$1"
if [ -z "$1" ]; then
        echo "$0 姓名或号码 消息"
        exit 1
else
        case "$NUM" in
               myself) shift
                        perlfetion.pl 138XXXXXXXX password 138XXXXXXXX "$*"
                        ;;
                *) perlfetion.pl 138XXXXXXXX password  "$*"
        esac
fi
exit 0 
想给脚本移植到台式机的cygwin平台下,但cygwin使用的GBK编码,perlfetion.pl使用的是utf-8编码。对shell脚本的字符串编码转换不熟悉。

代码: 全选

#/bin/bash
NUM="$1"
if [ -z "$1" ]; then
        echo "$0 姓名或号码 消息"
        exit 1
else
        case "$NUM" in
               myself) shift
                        MSG=$(echo "$*" | iconv -f gbk -t utf-8)
                        perlfetion.pl 138XXXXXXXX password 138XXXXXXXX ${MSG}
                        ;;
                *) perlfetion.pl 138XXXXXXXX password  "$*"
        esac
fi
exit 0 
提示:

iconv: (标准输入):1:2: 无法转换
Retrieving the config xml...
Retrieving the SSIAPP URL...
Retrieving the SIPC Address...
Trying to get the fetion number of the current account...
Connecting to the SIPC via TCP socket...
Login OK
Send SMS succeed

转码不成功,请大家指教。
回复