Skip to content

Instantly share code, notes, and snippets.

@dododevs
Last active July 21, 2019 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dododevs/7a78bedf4330841621ad8d38b1544cea to your computer and use it in GitHub Desktop.
Save dododevs/7a78bedf4330841621ad8d38b1544cea to your computer and use it in GitHub Desktop.
The magic of the expect command on Linux
#!/usr/bin/env expect
spawn bluetoothctl # start the process you want to talk with
expect -re {\[bluetooth\]} # wait for a particular input to come in based on the regex
send "default-agent" # generate whatever output and send it to the process
send "\n"
interact # drop to an interactive session with the open process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment