PDA

View Full Version : Shell script on QProcess with QString input



aksin
18th November 2014, 13:35
Dear all,

I have shell script like this :

input=input parameter1=value1 parameter2=value2 \
parameter3=value3 \

Expected result: Input from ui (input, value1textEdit, value2textEdit, value3textEdit) will added to script >> print it to current directory (.sh) >> view that file using gedit.


Here my progress:



void Mark::on_btnProcess_clicked()
{

QStringList str_input , str_command1, str_command2, str_command3;
str_input = ui->inputtextEdit->text();
str_command1 = ui->value1textEdit->text();
str_command2 = ui->value2textEdit->text();
str_command3 = ui->value3textEdit->text();

proc= new QProcess();
proc->start("echo , QStringList() << "input="<< QString(str_input)<<"parameter1="<<QString(str_command1)<<"parameter2="<<QString(str_command2)<<"parameter3="<<QString(str_command23)<<">> test.sh");
proc->start("gedit", QStringList() << "/current_dir/test.sh");

}

But its not working :(, any idea?


Thanks for advance,

Regard,

anda_skoa
18th November 2014, 18:18
Aside from your snippet missing a quote after "echo"?

Well, I doubt echo can deal with an argument ">> test.sh" the way you assume it would.
">> filename" on a shell is interpreted by the shell and takes the output of the program and appends it to "filename".
The program itself never sees that as part of its argument list.

What do you actually want to do?

Cheers,
_