Writing scripts to understand natural language is not particularly difficult, but Expect does not give any particular assistance for the task. Regular expressions by themselves are certainly not sufficient to describe arbitrarily complex patterns. In some situations, it is even reasonable to avoid using complex patterns and instead match input algorithmically, using Tcl commands.
Take the case of automating
ftp. In Chapter 3 (p. 83), I showed that it was very easy to retrieve a file if the name was known in advance—either by the script or the user. If the name is not known, it is harder. For example,
ftp does not support directory retrieval. This can be simulated by retrieving every file in the directory individually. (You can automate this to some degree using
ftp’s built-in wildcards, but that does not handle subdirectories so it is not a complete solution and I will ignore it for now.)
Further, imagine that you want to only retrieve files created after a certain date. This requires looking at a “long” directory listing. As an example, here is a listing of the directory
cd published/usenix250 CWD command successful. ftp>
ls -lt200 PORT command successful. 150 Opening ASCII mode data connection for /bin/ls. total 41 drwxrwsr-x 3 3 2 512 Sep 26 14:58 conference drwxr-sr-x 1695 3 21 39936 Jul 31 1992 faces lrwxrwxrwx 1 3 21 32 Jul 31 1992 bibliography -> /archive/doc/literary/obi/USENIX 226 Transfer complete. remote: -lt ...