PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

Expect

Expect

Expect is a pl created in 1990.

#496on PLDB 32Years Old 1.0kUsers
3Books 0Papers

Expect, an extension to the Tcl scripting language written by Don Libes, is a program to automate interactions with programs that expose a text terminal interface. Expect was originally written in 1990 for Unix systems, but has since become available for Microsoft Windows and other systems.. Read more on Wikipedia...


Example from the web:
# Assume $remote_server, $my_user_id, $my_password, and $my_command were read in earlier # in the script. # Open a telnet session to a remote server, and wait for a username prompt. spawn telnet $remote_server expect "username:" # Send the username, and then wait for a password prompt. send "$my_user_id\r" expect "password:" # Send the password, and then wait for a shell prompt. send "$my_password\r" expect "%" # Send the prebuilt command, and then wait for another shell prompt. send "$my_command\r" expect "%" # Capture the results of the command into a variable. This can be displayed, or written to disk. set results $expect_out(buffer) # Exit the telnet session, and wait for a special end-of-file character. send "exit\r" expect eof
Example from Wikipedia:
#timeout is a predefined variable in expect which by default is set to 10 sec #spawn_id is another default variable in expect. #It is good practice to close spawn_id handle created by spawn command set timeout 60 spawn ssh $user@machine while {1} { expect { eof {break} "The authenticity of host" {send "yes\r"} "password:" {send "$password\r"} "*\]" {send "exit\r"} } } wait close $spawn_id

Language features

Feature Supported Example Token
Comments
# A comment
Line Comments
# A comment
#
Semantic Indentation ϴ

Books about Expect from ISBNdb

title authors year publisher
Expect The Unexpected: A First Course In Biostatistics Raluca Balan; Gilles Lamothe 20170525 World Scientific Publishing
Windows 10 Primer: What to Expect from Microsoft's New Operating System Halsey, Mike 2015 Apress
Expect the Unexpected: A First Course in Biostatistics (Second Edition) Raluca Balan 2021 World Scientific Publishing Company
ratfor.html · expect.html · msp430.html

View source

PLDB - Build the next great programming language · v2022 · Day 32 · Docs · Build · Acknowledgements · Traffic Today · Traffic Trends · Mirrors · GitHub · feedback@pldb.com