Expect As A Daemon
When you log in to a host, you have to provide a username and (usually) a password. It is possible to make use of certain services without this identification. finger
and ftp
are two examples of services that can be obtained anonymously—without logging in. The programs that provide such services are called daemons. Traditionally, a daemon is a background process that is started or woken when it receives a request for service.
UNIX systems often use a program called inetd
to start these daemons as necessary. For example, when you ftp
to a host, inetd
on that host sees the request for ftp
service and starts a program called in.ftpd
(“Internet ftp
daemon”) to provide you with service. There are many other daemons such as in.telnetd
(“Internet telnet
daemon”) and in.fingerd
(“Internet finger
daemon”).
You can write Expect scripts that behave just like these daemons. Then users will be able to run your Expect scripts without logging in. As the large number of daemons on any host suggests, there are many uses for offering services in this manner. And Expect makes it particularly easy to build a daemon—to offer remote access to partially or completely automated interactive services. In the next section, I will discuss how to use Expect to enable Gopher and Mosaic to automate connections that would otherwise require human interaction.
Simple Expect scripts require no change to run as a daemon. For example, the following Expect script prints out the contents of /etc/motd ...
Get Exploring Expect now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.