Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

There's a script I'm running that installs a service. It has a couple of read commands.

I'd like to run it as a part of a bigger installation script (actually capistrano but it doesn't matter), and prefill the "read" parts with values, instead of blocking the entire process.

The script runs with a single command, let's say blah/bin/blah install, I'd like to supply input on the command, like input first_input, second_input | blah/bin/blah install

Relevant parts of the script:

      if [[ $NEO4J_USER == $wrapper_user ]]; then
        default_user=$wrapper_user
      else
        default_user="neo4j"
      fi

      ######### read:
      read -p "Graph-like power should be handled carefully. What user should run Neo4j? [$default_user] " proposed_user
      proposed_user=${proposed_user:-$default_user}
      if ! `id $proposed_user &> /dev/null` ; then

      ######### read:
        read -p "User \"$proposed_user\" does not yet exist. Shall I create the account for you? [Yn]" yn
        case $yn in
          [Nn]* ) echo "WARNING: Alright, but Neo4j will fail to launch until that user has been created."
          set_user $proposed_user
          ;;
        * ) create_user $proposed_user
          ;;

The entire script is at http://pastebin.com/RpJZciXq

I know I can change the script but I just want to prefill the values. Is it possible?

Well, in fact, it did matter I use capistrano because it has the ability to send input (see &block section).

But it's interesting to know if the functionality I mentioned exists in bash as well.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

read reads from stdin by default. Simply feed something there.

echo -e '\n\n' | blah/blah/blah install

blah/blah/blah install <<< $'\n\n'
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.