Problem with QProcess (extern Program)
-
wrote on 13 Jan 2021, 13:52 last edited by
Hello Forum,
as you probably already read in the headline, I have a problem with QProcess. I can't manage to start an external bash script with parameters.
The program compiles without errors and can also be started and runs to the end, but without starting the script.
I develop with the QT Creator on the OSX operating system (Big Sur).
QString program = "bashscriptTest"; QStringList arguments; arguments << "-o" << "TESTPARAMETER"; QProcess myProcess ; myProcess.start(program, arguments);
Kind regards
0815Joe -
Hello Forum,
as you probably already read in the headline, I have a problem with QProcess. I can't manage to start an external bash script with parameters.
The program compiles without errors and can also be started and runs to the end, but without starting the script.
I develop with the QT Creator on the OSX operating system (Big Sur).
QString program = "bashscriptTest"; QStringList arguments; arguments << "-o" << "TESTPARAMETER"; QProcess myProcess ; myProcess.start(program, arguments);
Kind regards
0815Joewrote on 13 Jan 2021, 15:02 last edited byIf you need a shell, you need to start the bash first.
Something like:
QString program = "/bin/sh"; QStringList arguments; arguments << "bashscriptTest" << "-o" << "TESTPARAMETER"; QProcess myProcess ; myProcess.start(program, arguments);
might work.
-
Hello Forum,
as you probably already read in the headline, I have a problem with QProcess. I can't manage to start an external bash script with parameters.
The program compiles without errors and can also be started and runs to the end, but without starting the script.
I develop with the QT Creator on the OSX operating system (Big Sur).
QString program = "bashscriptTest"; QStringList arguments; arguments << "-o" << "TESTPARAMETER"; QProcess myProcess ; myProcess.start(program, arguments);
Kind regards
0815Joe -
If you need a shell, you need to start the bash first.
Something like:
QString program = "/bin/sh"; QStringList arguments; arguments << "bashscriptTest" << "-o" << "TESTPARAMETER"; QProcess myProcess ; myProcess.start(program, arguments);
might work.
wrote on 13 Jan 2021, 16:24 last edited by JonB@Pl45m4 said in Problem with QProcess (extern Program):
QString program = "/bin/sh";
You might rather want
QString program = "/bin/bash";
:DYou could instead make the first line of your script be
#!/bin/bash
and make the file executable viachmod +x bashscriptTest
. Then your original code ofQString program = "bashscriptTest";
should work as-is (with its arguments). -
wrote on 13 Jan 2021, 20:07 last edited by
At first thank you all for your help.
But nothing is working.
-
@0815Joe said in Problem with QProcess (extern Program):
But nothing is working.
That's no proper error report. Please show what you've done.
-
Hi
Where is the script ?
You just say "bashscriptTest" (with no paths to the script file)
so for Qt to find it, it must be right next to the .exe or
in some place where it will search for it. (system paths) -
wrote on 13 Jan 2021, 22:06 last edited by JoeCFD
your qt app path might be different from where the script is located. Add absolute path to bashscriptTest and your code will be good.
-
@JoeCFD The bashscriptTest is also in the build path.
i will try the absolute path later today.Then i am giving you an answer :-)
-
@0815Joe
I don't know what "the build path" is, but it doesn't sound like it would be available/have any significance at runtime (outside of Qt Creator).wrote on 8 Feb 2021, 15:00 last edited byHello to all who helped me.
I am sorry, but my program worked from the beginning.
I just did not find the result file.
Problem: I have an OSX operating system and my GUI sample application is a package. In this package is also my result file. This I did not know and then of course overlooked.