Results 1 to 2 of 2

Thread: Shell script on QProcess with QString input

  1. #1
    Join Date
    Nov 2014
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Shell script on QProcess with QString input

    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:


    Qt Code:
    1. void Mark::on_btnProcess_clicked()
    2. {
    3.  
    4. QStringList str_input , str_command1, str_command2, str_command3;
    5. str_input = ui->inputtextEdit->text();
    6. str_command1 = ui->value1textEdit->text();
    7. str_command2 = ui->value2textEdit->text();
    8. str_command3 = ui->value3textEdit->text();
    9.  
    10. proc= new QProcess();
    11. proc->start("echo , QStringList() << "input="<< QString(str_input)<<"parameter1="<<QString(str_command1)<<"parameter2="<<QString(str_command2)<<"parameter3="<<QString(str_command23)<<">> test.sh");
    12. proc->start("gedit", QStringList() << "/current_dir/test.sh");
    13.  
    14. }
    To copy to clipboard, switch view to plain text mode 

    But its not working , any idea?


    Thanks for advance,

    Regard,

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Shell script on QProcess with QString input

    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,
    _

Similar Threads

  1. Replies: 4
    Last Post: 22nd April 2014, 16:34
  2. Accesing linux shell script from Qt
    By Ricardo_arg in forum Qt Programming
    Replies: 2
    Last Post: 17th February 2011, 13:49
  3. QProcess: how to run shell script with password?
    By cutie.monkey in forum Qt Programming
    Replies: 0
    Last Post: 23rd March 2010, 06:43
  4. Call script shell with Qt
    By zeeb100 in forum Qt Programming
    Replies: 6
    Last Post: 26th February 2009, 10:17
  5. How to use shell script files ?
    By npc in forum Newbie
    Replies: 3
    Last Post: 15th February 2007, 09:26

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.