title: sending more commands to pexpect child after spawn
body: <p>I am learning how to use pexpect. My goal is getting a list of directories, then recreate those directory in another folder by using pexpect. However, how do I send multiple of commands into a pexpect child in a python loop? <code>child.sendline()</code> doesnt work for me =[. I have been respawning the child, but that doesnt seem like the proper way of doing it.</p>
  
  <pre><code>import pexpect
  child = pexpect.spawn("""bash -c "ls ~ -l | egrep '^d'""")
  child.expect(pexpect.EOF)
  tempList = child.before
  tempList = tempList.strip()
  tempList = tempList.split('\r\n')
  listofnewfolders = []
  for folder in tempList:
      listofnewfolders.append(folder.split(' ')[-1])
  for folder in listofnewfolders:
      child.sendline("""bash -c 'mkdir {0}'""".format("~/newFolder/%s" % folder))
  </code></pre>