Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Shellscript with "pre-configured" input, please read for explanation

OK, so basically this is what I wanna do with a shellscript (bash):
Inside my shellscript I run a command that requires a couple of inputs, i.e. it asks questions that the user will have to answer. Now I'd like to preset this input so that when said command asks the questions they are automatically answered without the user having to type anything.

For example, let's say I was running the command ssh-keygen. When run it would ask two questions, where to store the generated ssh-key and if the existing key should be overwritten. What I wanna do might be to have the first question automatically answered with [ENTER] and the second with "y+[ENTER]".

Did that make sense? I hope so.
Does anybody know a way to do this?
----
"codito, ergo sum"

Comments

  • akalexi312akalexi312 Member Posts: 31
    I can suggest a better, rather say professional way to do this.Supply your script a configuration file that holds configuration parameters
    in the form of

    export Config-param=Value

    on each line.Then in your main script call this config file by invoking in current shell like

    . ./script-config.sh

    Then use the config parameters to decide what was supplied and act accordingly.Let me know in case i have confused you because supplying
    a config file is somthing you were not expecting i think ?

    : OK, so basically this is what I wanna do with a shellscript (bash):
    : Inside my shellscript I run a command that requires a couple of inputs, i.e. it asks questions that the user will have to answer. Now I'd like to preset this input so that when said command asks the questions they are automatically answered without the user having to type anything.
    :
    : For example, let's say I was running the command ssh-keygen. When run it would ask two questions, where to store the generated ssh-key and if the existing key should be overwritten. What I wanna do might be to have the first question automatically answered with [ENTER] and the second with "y+[ENTER]".
    :
    : Did that make sense? I hope so.
    : Does anybody know a way to do this?
    : ----
    : "codito, ergo sum"
    :



Sign In or Register to comment.