Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    Run a shell script in a own QT-Application

    Reply
    Dr.Heyde | # 1 | 2010-07-26, 17:52 | Report

    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

    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 ?

    Edit | Forward | Quote | Quick Reply | Thanks

     
    d-iivil | # 2 | 2010-07-26, 19:53 | Report

    Originally Posted by Dr.Heyde View Post
    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

    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?

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to d-iivil For This Useful Post:
    Dr.Heyde

     
    Joorin | # 3 | 2010-07-26, 20:21 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to Joorin For This Useful Post:
    Dr.Heyde

     
    Dr.Heyde | # 4 | 2010-07-26, 20:22 | Report

    Hi & Thx 4 Reply D-livil

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

    Originally Posted by
    #! /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

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by Dr.Heyde; 2010-07-26 at 21:03.

     
    qwerty12 | # 5 | 2010-07-27, 02:15 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to qwerty12 For This Useful Post:
    Dr.Heyde

     
    benlau | # 6 | 2010-07-28, 00:37 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to benlau For This Useful Post:
    Dr.Heyde

     
    Dr.Heyde | # 7 | 2010-07-28, 03:43 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Dr.Heyde | # 8 | 2010-08-01, 15:54 | Report

    ...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)

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to Dr.Heyde For This Useful Post:
    qwerty12

     
vBulletin® Version 3.8.8
Normal Logout