#/usr/bin/python import pexpect import time from subprocess import * child = pexpect.spawn('pnatd'); child.send('at\r'); time.sleep(0.25); child.send('at+cusd=1,"*100#",15\r'); time.sleep(0.25); child.readline(); child.readline(); child.readline(); reply = child.readline(); start = reply.find('"'); end = reply.find('"', start+1); reply = reply[start+1:end]; child.sendeof(); p = Popen(['sh', 'ucsdecode.sh', reply], stdout=PIPE); print p.communicate()[0];
#/bin/sh echo "$1" | echo -n -e $(tr -d '[:space:]' | sed 's/../\\x&/g') | iconv -f UCS-2BE -t UTF8