I need to make a shell over OpenSSH as part of Windows 10. I can't get the output of the console application using QProcess. If an error occurs and the application shuts down, I will get the output. If ssh asks for the password, I can't get this request.
#include "sshshell.h"
#include <QDebug>
#include <QTextCodec>
SSHShell::SSHShell(QObject *parent)
: QObject{parent}
{
process = new QProcess(this);
process->setReadChannel(QProcess::StandardOutput);
connect(process,SIGNAL(readyRead()),this,SLOT(ReadyReadSlot()));
// connect(process,SIGNAL(readyReadStandardOutput()),this,SLOT(ReadOutputData()));
// connect(process,SIGNAL(readyReadStandardError()),this,SLOT(ReadOutputData()));
}
void SSHShell::startSSH()
{
qDebug()<<"startSSH()";
process->start("ssh.exe", QStringList()<< "-D"<<"5555" <<"-N"<<"[email protected]");
qDebug()<<process->
}
void SSHShell::ReadOutputDataSlot()
{
qDebug()<<"ReadOutputData()()";
QByteArray ba = process->readAllStandardOutput();
QTextCodec *codec = QTextCodec::codecForName("IBM 866");
QString out = codec->toUnicode(ba);
emit sendText(out);
}
void SSHShell::ReadyReadSlot()
{
qDebug()<<"mReadyRead()()";
QByteArray ba = process->readAllStandardOutput();
QTextCodec *codec = QTextCodec::codecForName("IBM 866");
QString out = codec->toUnicode(ba);
emit sendText(out);
}
I've tried connecting with different signals, but the result is always the same. I can't get output if ssh interacts with me (asks for a password or key). Help me figure it out.