Pexpect is a pure Python module for spawning child applications; controlling them; and responding to expected patterns in their output. Pexpect allows your script to spawn a child application and control it as if a human were typing commands. Pexpect can be used for automating interactive applications such as ssh, ftp, passwd, telnet, etc. It can be used to a automate setup scripts for duplicating software package installations on different servers. It can be used for automated software testing. The Pexpect interface was designed to be easy to use.
Download the current version from sourceforge site.
Under the pexpect-2.1 directory you should find the examples directory. This is the best way to learn to use Pexpect. See the descriptions of Pexpect Examples.
the following are experimental extensions to Pexpect
Download BitBake recipe from here. Using MokoMakefile tool train:
cp python-pexpect_2.1.bb $OMDIR/openembedded/packages/python
bitbake python-pexpect
$OMDIR/build/tmp/deploy/glibc/ipk/armv4tpython-pexpect_2.1-r0_armv4t.ipk
Using SCP to upload the ipk file to neo
ipkg install -d card armv4tpython-pexpect_2.1-r0_armv4t.ipk
ipkg files python-pexpect ipkg files python-io export PYTHONPATH="/media/card/ipkg/usr/lib/python2.5/site-packages/: \ /media/card/ipkg/usr/lib/python2.5/lib-dynload/:/media/card/ipkg/usr/lib/python2.5/"
python -c "import pexpect"
child = pexpect.spawn('libgsmd-tool -m shell') child.sendline('O') child.expect(['Power-On','ERROR','OK'])
NOTE: we may consider to use pexpect to do some auto tests for GSM functions |