how to answer questions in cmd using shelljs

187 views Asked by At

I'm putting together a script to create certificates for my devices, I thought I'd use shelljs to run these commands. I created a basic command for certificate generation, but the script stops running when cmd has a question, as in the example:

const shell = require('shelljs')
shell.exec("openssl genrsa -out deviceCert.key 2048")
shell.exec("openssl req -new -key deviceCert.key -out deviceCert.csr")

enter image description here

I would like to know if there is any command that I can use to answer these cmd questions by shelljs itself.

1

There are 1 answers

1
kawadhiya21 On

Try something like this:

shell.exec("echo -ne 'AU' | openssl req -new -key deviceCert.key -out deviceCert.csr")