PDA

View Full Version : qprocess and shell



GuL
12th February 2009, 00:48
I would like to execute a shell command using qprocess, but I would like to pass diferent arguments:

QString prog = "/bin/bash";
QStringList arguments;
arguments << "-c" << "gksudo -- mount -o loop /media/100GB/test.iso /media/iso";
QProcess* process = new QProcess(this);
process->start(prog , arguments);
process->waitForFinished();
QString tmp = process->readAll();
qDebug() << tmp;
ui.textEdit->append( "Path to file: " + ui.label_dir->text() + ui.label_file->text() );
ui.textEdit->append(tmp);

like these:


arguments << "-c" << "gksudo -- mount -o loop" << "/media/100GB/test.iso" << "/media/iso";

How can I do that?

talk2amulya
12th February 2009, 05:47
well, when u run a command using QProcess, u pass the whole command as one argument ONLY.. so the right way to do it as u have done here:


arguments << "-c" << "gksudo -- mount -o loop /media/100GB/test.iso /media/iso";

so if u wanna pass different arguments, at the end of the day u have add them to the command as ONE string