简体   繁体   中英

How to use several commands through the pipe as shell script

I am using firebase.

I want to write a shell script that do the following: Executing two commands:

  1. firebase init
  2. firebase deploy

The problem is that firebase init prompts with several questions. The first one I want to answer with y for yes and enter afterwards. Then press the key space to deselect one item and enter to continue. A few other questions follow.

But I cannot make firebase init to accept the first entries I mentioned above.

When I use "echo y | firebase init" it works. But when I add the space key and enter firebase init exits without doing what it should.

Is it possible to solve this problem. I am new to shell scripting. I am using Cygwin with Windows 7.

From the docs the firebase init command just creates the file firebase.json . Why not do it interactively then just manually generate the JSON later?

Ie if you do it and it generates

{
  "firebase": "myfirebase",
  "public": "app",
  "ignore": [
    "firebase.json",
    "**/.*",
    "**/node_modules/**"
  ]
}

then you can just do

$ echo $'{\n  "firebase": "myfirebase",\n  "public": "app",\n  "ignore": [\n    "firebase.json",\n    "**/.*",\n    "**/node_modules/**"\n  ]\n}\n' >firebase.json
$ firebase deploy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM