# This connects to the openbsd ftp site and# downloads the recursive directory listing.importpexpectchild=pexpect.spawn('ftp ftp.openbsd.org')child.expect('Name .*: ')child.sendline('anonymous')child.expect('Password:')child.sendline('noah@example.com')child.expect('ftp> ')child.sendline('cd pub')child.expect('ftp> ')child.sendline('get ls-lR.gz')child.expect('ftp> ')child.sendline('bye')