SHELL脚本编码转换问题(关于在cygwin下如何使用perlfetion发送免费短信)
发表于 : 2010-05-27 21:59
使用的perl脚本来至于csksoft发送fetion,地址如下:
perlfetion.pl
在Ubuntu下编写了一个小脚本,存储手机号码和密码,实现别名发送。
想给脚本移植到台式机的cygwin平台下,但cygwin使用的GBK编码,perlfetion.pl使用的是utf-8编码。对shell脚本的字符串编码转换不熟悉。
提示:
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
转码不成功,请大家指教。
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
代码: 全选
#/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
转码不成功,请大家指教。