PDA

View Full Version : Shell script execution using Qprocess



Khaledadelll
13th December 2018, 11:34
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:

#tri1 decoding
utils/mkgraph.sh data/lang_test exp/tri1 exp/tri1/graph
echo "Hi there"


The code i wrote:


QStringList program ;
program<< "-c"<<"bash /home/dell2/Desktop/ll.sh";


QProcess exec;
exec.start("/bin/sh",program);
exec.waitForFinished();

tuli
13th December 2018, 13:10
You probably have to set a working directory - setWorkingDirectory()?

Khaledadelll
13th December 2018, 17:23
Yes! That's exactly was the problem ... Thank you very much

Ginsengelf
14th December 2018, 08:08
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