@Utopia

Как подтвержить консольную комманду через Node.js?

import * as cp from 'child_process'
const ls = cp.spawn('cmd ssh -tt git@bitbucket.org', {})

ls.stdout.on('data', function (data) {
    const currentData = data.toString();
    console.log("stdout");

    //check for password input notification:
    if(currentData === "authenticity of host")
    {
        //send the password via stdin. \n does the trick over here.
        ls.stdin.write('yes\n');
    }
});
ls.stderr.on('data', function (data) {
    const currentData = data.toString();
    console.log("stderr");

    //check for password input notification:
    if(currentData === "authenticity of host")
    {
        //send the password via stdin. \n does the trick over here.
        ls.stdin.write('yes\n');
    }
});

Выдает в консоли:
The authenticity of host 'bitbucket.org (104.192.141.1)' can't be established.
RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
Как подтвердить из Node - условно нажать yes.

От куда я вообще получаю в консоли это сообщение если это не ls.stdout и не ls.stderr?
  • Вопрос задан
  • 59 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы