I have created a little GUI with QT Designer/Creator. Now I want to execute a Shell Script by pushing a button. I have already connected the button to a methode. In the method I now have to write the code for starting the Shell Script.
I tried it with the QProcess class:
1 2 3 4 5
QString program = "/bin/sh";
QString shellFile = "Shell.sh";
QProcess *myProcess = new QProcess(this);
myProcess->setStandardInputFile(shellFile);
myProcess->start(program);
--> No result. I can compile without problems, but when clicking the button nothing happens.
Furthermore I tried it with the system function (stdlib.h class):
Assuming the file is yours, all (I think) you need to do is open a terminal and type this: chmod +x yourfile
...where yourfile is... your file. This'll allow running of the file. Good luck! ;)
By the way... why are you mixing C++ and shell scripts? :/
I have written a GUI and now I have to start a Shell Script by using one button of the GUI. Therefore I mix c++ and shell scripts.
Another question:
Because the shellscript I want to run is always created new when using the GUI I need to change the standard file rights for new created files/directories. I know I have to change the file /etc/profile by using the terminal, but I don know how to do this. The file rights for new files are 0002 as standard (proofed with unmask), so I thought changing it to 0777 would be the best. Do you or does anybody know how to do this?
Wait wait wait. Your question is on how to ensure that the file you're creating will have permission to run, correct? If so, there there are a few C functions that could help you with that.
Thx for the answer - the given documentation is very interesting though I have to handle my source code now in another way, because my tutor wants so. Now I will have to run the ShellScript, not by running the ShellScript itself, but by running the commands of the ShellScript in my source code. But I'm already working on that.