port a recptx perl script to shell script.