Results 1 to 4 of 4

Thread: How to shutdown Linux machine from QT Program?

  1. #1
    Join Date
    Mar 2010
    Posts
    68
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default How to shutdown Linux machine from QT Program?

    I try to use QProcess:execute("/sbin/poweroff") but nothing happen. Some body help me a way to do?

  2. #2

    Default Re: How to shutdown Linux machine from QT Program?

    I'm not on a Linux machine at the moment but what happens if you try:

    QStringList arguments << "-h" << "now";
    QProcess:execute("shutdown", arguments)

    (if you don't post for the next 3 minutes I'll assume it worked )

  3. #3
    Join Date
    Mar 2010
    Posts
    68
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: How to shutdown Linux machine from QT Program?

    Thank for your helping!

    The problem is the shutdown command require root for shutting down, but my program run as user account.

  4. #4
    Join Date
    Mar 2006
    Location
    San Francisco, CA
    Posts
    23
    Thanks
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to shutdown Linux machine from QT Program?

    You need to chown it to root and set the SUID bit on your application. That way when another user runs your program it wil run as root instead of them. As this is a potential security hole make sure only root has write permission.

Similar Threads

  1. Replies: 1
    Last Post: 15th August 2010, 11:13
  2. Replies: 7
    Last Post: 3rd June 2008, 11:08
  3. how to execute program that using qsqlite on different machine?
    By mismael85 in forum Installation and Deployment
    Replies: 2
    Last Post: 19th March 2008, 21:09
  4. Replies: 3
    Last Post: 5th February 2008, 06:32
  5. Porting my program to another windows machine !
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 14th March 2007, 06:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.