Expect is a tool for automating interactive applications. Expect was constructed using Tcl, a language library designed to be embedded into applications.
Example code :
# 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" Reference : https://en.wikipedia.org/wiki/Expect