#!/usr/bin/env python
import pexpect
child = pexpect.spawn ('ftp *.*.*.*')
child.expect ('Name .*: ')
child.sendline ('user')
child.expect ('Password:')
child.sendline ('****')
child.expect ('ftp> ')
child.sendline ('cd .')
child.expect('ftp> ')
child.sendline ('get file')
child.expect('ftp> ')
child.sendline ('bye')