Automatically feed input to Linux command line

If I have a linux command that prompts for 2 or more input, how can these inputs be passed to the prompt by defining it in the command line? Is there something you can add behind the command to do this?

In the example below, how can you run the command and pass it the username and password without having to type it in when the system asks for them?

  • Facing image uploading error in interventoin / laravel 4.2
  • Send string with whitespaces as git commit message using bash
  • How to run bash script after git push
  • Linux - run multiple parallel commands, print sequential output
  • cent os bash unrecognized option --system on adduser command
  • Specify private SSH-key to use when executing shell command with or without Ruby?
  • Example command that asks for username and password

    git clone https://github.com/username/repo.git 
    

    Just an example, please don’t suggest doing the git clone using ssh instead of http, or that its insecure to expose the password in the command

  • Understanding git and checkout
  • Working in a git branch with submodules and commiting directly from that branch
  • Merge changes of copied repository without true common ancestor in git
  • Is it possible to get the git tag with “go get”?
  • BFG is removing sensitive content everywhere but in the penultimate commit
  • How to locate the git config file in Mac
  • 3 Solutions collect form web for “Automatically feed input to Linux command line”

    The “expect” package is built for this kind of thing.
    If you install it, check out “autoexpect”.

    Depending on why you want to do this, you may want to explore ways to use github repositories without passwords:

    https://help.github.com/articles/managing-deploy-keys

    Perhaps this

    {
      echo user
      echo pass
    } | git clone https://github.com/username/repo.git
    

    ref

    Git Baby is a git and github fan, let's start git clone.