[Qt-interest] ssh2 (ssh tectia client) with QProcess

yogesh upreti yogesh.upreti at gmail.com
Mon Sep 19 16:06:44 CEST 2011


Hello All,
I am trying to execute some shell commands using my Qt Application.

For this I use following code:

QString SSHCommand::start(jobs *j)
     QProcess *process = new QProcess();
    QStringList env = QProcess::systemEnvironment();
    process->setEnvironment(env);
    process->setWorkingDirectory(j->dir);
    process->start(j->command,j->arg);
    QString str1 += QString("PID: %1\n").arg((qint64)process->pid());
    process->waitForFinished();
    QByteArray data = process->readAll();
    QString str = QString(data);
    str1 += str;
    return str
}

I have a list of jobs to be executed and for this, I make a
   QList<jobs *j> ListOfJob
and run it using
    QtConcurrent::mapped(ListOfJob,&start) //start is a static function

In my execution before j->command use to be a Windows .bat file that
contains some batch commands to be executed. That time everything was ok.

Now I have a .bat file which contains the following line :
ssh2 unixUserHost /root/user/temp/scripts/ssh.sh
when I execute this .bat file in cmd, I have things done properly, it opens
a connection; execute the .sh file; and gives me an output.
but when I run it using QProcess it executes it properly but the ssh2
command doesn't terminates. I can see it still running in the Task manager.
and Qt program is waiting for it to stop, and I have nothing.

Do someone have similier problem using ssh2 command??? Do I have problem
with QProcess definition or I have problem with ssh2 command.

Any help would be nice.

Thanks
Yogesh Upreti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110919/51da6633/attachment.html 


More information about the Qt-interest-old mailing list