maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Run a shell script in a own QT-Application (https://talk.maemo.org/showthread.php?t=59199)

Dr.Heyde 2010-07-26 17:52

Run a shell script in a own QT-Application
 
Hi there,

i've written a qt app with the QT Creator...just a simple one.
For testing only, i've add a combobox and a "Apply" Button.

The Button should run a shell script, which should do something.
(with Variable from the combobox).

My Problem is, that nothing happend, when i push the Button :mad:

The part of the Button looks so:

Code:

void MainWindow::on_applypush_clicked()
{
    QStringList combo;
    combo << ui->comboBox->currentText();
    QProcess *process = new QProcess(this);
    process->start("./sbin/xicon", combo);
}

Could anyone help me, with my Problem ?

d-iivil 2010-07-26 19:53

Re: Run a shell script in a own QT-Application
 
Quote:

Originally Posted by Dr.Heyde (Post 765492)
Hi there,

i've written a qt app with the QT Creator...just a simple one.
For testing only, i've add a combobox and a "Apply" Button.

The Button should run a shell script, which should do something.
(with Variable from the combobox).

My Problem is, that nothing happend, when i push the Button :mad:

The part of the Button looks so:

Code:

void MainWindow::on_applypush_clicked()
{
    QStringList combo;
    combo << ui->comboBox->currentText();
    QProcess *process = new QProcess(this);
    process->start("./sbin/xicon", combo);
}

Could anyone help me, with my Problem ?

Is your script executable (chmod a+x /sbin/xicon)?
You can also leave out the . -mark from QT-code.

And one more thing, you are running your QT-app as user, not as root are you?

Joorin 2010-07-26 20:21

Re: Run a shell script in a own QT-Application
 
I'd start with the path to the binary. As pointed out above. the "." makes a difference.

With a path starting with ".", it becomes a relative path, relative to whatever the Qt application has as current working directory.

So, remove that and try again.

Dr.Heyde 2010-07-26 20:22

Re: Run a shell script in a own QT-Application
 
Hi & Thx 4 Reply D-livil

1st.: i start script 1 with following inserts :

Quote:

#! /bin/sh -e
sudo zicon
Sript 2(zicon) is the "real" shell.

So, yes...it`s start as root

Im really new to Qt so, sorry for my bad knowledge *g

Is'it working if i make the execution (chmod a+x /sbin/xicon) in a linux system an copy the Files to the place ?
Or have i to go another Way?

Kind Regards

€dit: I remove the "."
€dit2: It dosent work for me :(

and hmm, how do i start the qt app.....i start it with the button *gg*
how i said....im really ,really new to qt an i'm very thankfully for every tip !

here's my cpp + h... have i anything forgotten ?

http://pastie.org/1061122

http://pastie.org/1061127

qwerty12 2010-07-27 02:15

Re: Run a shell script in a own QT-Application
 
Hi,

RE. the script: You have whitelisted zicon in /etc/sudoers.d (and ran update-sudoers afterwards)? If you haven't, sudo's gonna be waiting asking for a password. And depending on the way you've written the could-be sudoers file, running "sudo zicon" as root will make sudo do absolutely nothing

benlau 2010-07-28 00:37

Re: Run a shell script in a own QT-Application
 
I think it is related to the path setting / or exec bits. You may verify by process->error() (or capture the error() signal) . If It is QProcess::FailedToStart , then it was not able to start the program.

Dr.Heyde 2010-07-28 03:43

Re: Run a shell script in a own QT-Application
 
Well, i think, that the Problem is from the other side....
I've the directory "Data" with all my realated Files in Subdirectories, but the Problem seems to be, that the Files are after the installation gone ?!? I don`t know how,but they are gone....*gg
My "Sudoers File" -->gone
My "scripts"-->gone.
Such Problems on so a simple thing....can´t believe it..
I´m searching over and over....

KR

Dr.Heyde 2010-08-01 15:54

Re: Run a shell script in a own QT-Application
 
...got it....it was a sudoers problem...thank you qwerty12 and all the others who helped me !

Now, is there a way to reboot the system with a Clicked Signal....?

I mean this solution :
Code:

dbus-send --system --type=method_call --print-reply --dest=com.nokia.mce "/com/nokia/mce/request" com.nokia.mce.request.req_reboot
should not be the best one....

Or do I have to make a shellscript with an simple " reboot" inside. (ofcourse, with sudo rights)


All times are GMT. The time now is 10:09.

vBulletin® Version 3.8.8