Expect

expect
Using Expect Scripts to Automate Tasks
6 Expect Script Examples to Expect the Unexpected
Expect Script Tutorial: Expressions, If Conditions, For Loop, and While Loop Examples
Tcl – How to Locate Include File to Source

User input

How can I make an expect script prompt for a password?

# grab the password
stty -echo
send_user -- "Password for $user@$host: "
expect_user -re "(.*)\n"
send_user "\n"
stty echo
set pass $expect_out(1,string)

#... later
send -- "$pass\r"

Tcl

Expect Examples
Regular Expressions
Regular Expression Examples

$ ./5410debug.exp 
bash: ./5410debug.exp: /usr/bin/expect: bad interpreter: No such file or directory

$ sudo yum install expect
Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package expect.x86_64 0:5.45-10.fc20 will be installed
--> Finished Dependency Resolution
[...]
Installed:
  expect.x86_64 0:5.45-10.fc20
Complete!

Leave a Reply

Your email address will not be published. Required fields are marked *