Calling ftp commands from python
draghuram at gmail.com
draghuram at gmail.com
Wed Aug 31 16:59:05 EDT 2005
Your best bet would be to use "pexpect" module. Code may look something
like:
import pexpect
import sys
child = pexpect.spawn ('ftp ftp.site.com')
child.expect ('Name .*: ')
child.sendline ('username')
child.expect ('Password:')
child.sendline ('password')
child.expect ('ftp> ')
child.sendline ('cd testdir')
child.expect ('ftp> ')
child.sendline ('bin')
child.expect ('ftp> ')
child.sendline ('hash')
child.expect ('ftp> ')
child.sendline ('get testfile')
child.expect ('ftp> ')
print child.before
child.sendline ('bye')
Raghu.
~
More information about the Python-list
mailing list