Skip to content

Instantly share code, notes, and snippets.

@imranbhullar
Created March 12, 2018 04:49
Show Gist options
  • Save imranbhullar/0c00a32a502ddd9a8fc236020fdfe070 to your computer and use it in GitHub Desktop.
Save imranbhullar/0c00a32a502ddd9a8fc236020fdfe070 to your computer and use it in GitHub Desktop.
using pexpect to play with FTP
import pexpect
child = pexpect.spawn ('ftp ftp.freebsd.org')
child.expect ('Name .*: ')
child.sendline ('anonymous')
child.expect ('Password:')
child.sendline ('me@mydomain.com')
child.expect ('ftp> ')
child.sendline('cd /pub/FreeBSD')
child.expect('ftp>')
child.sendline('get README.TXT')
child.expect('ftp> ')
child.sendline ('bye')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment