#!/usr/bin/env pythonpython
#coding:utf-8ide
import pexpectspa
child = pexpect.spawn('ftp ftp.openbsd.org') # 運行ftp命令.net
info = file('ftpinfo.txt', 'w') # 記錄鏈接日誌信息日誌
child.logfile = infoutf-8
child.expect('Name .*: ') it
child.sendline('anonymous') # 輸入ftp帳號信息class
child.expect('Password') # 匹配密碼輸入提示import
child.sendline('pexpect@sourceforge.net') # 輸入ftp密碼ftp
# 調用interact()讓出控制權,用戶能夠繼續當前的會話手工控制子程序
child.interact()
child.close()