Results 1 to 4 of 4

Thread: Shell script execution using Qprocess

  1. #1
    Join Date
    Dec 2018
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Shell script execution using Qprocess

    I am trying to execute a shell script using qprocess that calls another shell scripts. The problem is that the program skips any other calling to other scripts and executes the next command
    The script:
    Qt Code:
    1. #tri1 decoding
    2. utils/mkgraph.sh data/lang_test exp/tri1 exp/tri1/graph
    3. echo "Hi there"
    To copy to clipboard, switch view to plain text mode 

    The code i wrote:
    Qt Code:
    1. QStringList program ;
    2. program<< "-c"<<"bash /home/dell2/Desktop/ll.sh";
    3.  
    4.  
    5. QProcess exec;
    6. exec.start("/bin/sh",program);
    7. exec.waitForFinished();
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Shell script execution using Qprocess

    You probably have to set a working directory - setWorkingDirectory()?

  3. The following user says thank you to tuli for this useful post:

    Khaledadelll (13th December 2018)

  4. #3
    Join Date
    Dec 2018
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Shell script execution using Qprocess

    Yes! That's exactly was the problem ... Thank you very much

  5. #4
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Shell script execution using Qprocess

    Hi, just a small remark: you effectively call "sh -c bash /home/dell2/Desktop/ll.sh", which means that you start a shell (sh) to start a shell (bash) to run your script. One of these shells can be removed.

    Ginsengelf

Similar Threads

  1. Killing QProcess shell script
    By mister_m in forum Qt Programming
    Replies: 6
    Last Post: 19th August 2016, 18:08
  2. Replies: 1
    Last Post: 18th November 2014, 19:18
  3. Replies: 4
    Last Post: 22nd April 2014, 16:34
  4. QProcess: how to run shell script with password?
    By cutie.monkey in forum Qt Programming
    Replies: 0
    Last Post: 23rd March 2010, 06:43
  5. Call script shell with Qt
    By zeeb100 in forum Qt Programming
    Replies: 6
    Last Post: 26th February 2009, 10:17

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.