added pexpect script

stolen from Dan, modified so depends on number of cores