Helpful Command: Use Expect Language in Linux Bash


Expect programming has it’s own language that gives the ability to simulate a terminal behaviour
Example below shows Expect code snippet in bash, that requires a password to be entered by the user:
RESULT=$(expect – << EOF
spawn scp -r username@hostname:
expect “Password:”
send “mycomplexpassword\r”
send — “\r”
expect eof
EOF)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s