Search code examples
linuxbashscriptinginteractive

Bash script without interacting


I would like to do following:

I have a bash script that calls an interactive command that asks the user for a passphrase. I want to specify the passphrase in the script as a variable, and pass that variable to the command non-interactively.


Solution

  • I believe you would like to look into expect. This utility is designed specifically for typing on behalf of the user.

    Assuming your script has a prompt (or a line that dependably appears before user interaction is required), expect can parse the output, and when it sees the line, e.g., 'passphrase:', enter your passphrase and continue execution of the script.