Skip to content
Snippets Groups Projects
Commit b4a4aa2f authored by Per Cederqvist's avatar Per Cederqvist
Browse files

New demo program, that uses the traditional API.

parent e5a22d9b
No related branches found
No related tags found
No related merge requests found
# The mandatory ftp example, in traditional style.
import pcl_expect
pcl_expect.stty_init = "-onlcr -ocrnl"
ftp = pcl_expect.spawn("ftp ftp.funet.fi")
def send_anon(exp):
exp.send("anonymous\n")
return pcl_expect.CONT
def send_user(exp):
exp.send("ceder@lysator.liu.se\n")
return pcl_expect.CONT
ret, exp = pcl_expect.expect([
(pcl_expect.RE, ftp, "Name.*:", send_anon),
(pcl_expect.RE, ftp, "Password.*:", send_user),
(pcl_expect.RE, ftp, "ftp> "),
])
assert ret == 2
assert exp == ftp
ftp.send("cd pub\n")
pcl_expect.expect([(pcl_expect.RE, ftp, "(?s).*ftp> ")])
ftp.send("passive\n")
pcl_expect.expect([(pcl_expect.RE, ftp, "(?s).*ftp> ")])
ftp.send("dir\n")
ret, exp = pcl_expect.expect([(pcl_expect.RE, ftp, "(?s).*ftp> ")])
if ret == 0:
print ftp.match.group()
ftp.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment