Results 1 to 3 of 3

Thread: QProcess unable to start shell commands linux

  1. #1
    Join Date
    Mar 2011
    Location
    Greece
    Posts
    23
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QProcess unable to start shell commands linux

    I would like to execute shell commands using QProcess,i have searched forum and read documentation but i can't solve my problem.
    For example,

    cmdline="/bin/bash";
    arguments << "-c" << "sudo apt-get install";
    process->start(cmdline,arguments,QIODevice::ReadWrite);
    The result of above program is:
    sudo: no tty present and no askpass program specified

    If the arguments are:
    arguments << "-c" << "ls -l";
    then the function is executed correctly.

    i have edited sudoers file using visudo in order not to ask password for a specific user.
    Thanks!
    Last edited by milli; 13th March 2011 at 21:54.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QProcess unable to start shell commands linux

    The problem is obviously with sudo and not with Qt.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    milli (14th March 2011)

  4. #3
    Join Date
    Mar 2011
    Location
    Greece
    Posts
    23
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default [SOLVED]: QProcess unable to start shell commands linux

    As wysota wrote, the problem was with sudo. (The command was not executing due to editting sudoers file).
    If someone else has similar problem the following code works:
    QString apath,program;
    QStringList args;
    apath=QDir("/bin/bash").absolutePath());
    program="gksudo";
    args << "apt-get install";
    process->start(program,args);

Similar Threads

  1. Replies: 12
    Last Post: 11th September 2010, 02:39
  2. QProcess: how to run shell script with password?
    By cutie.monkey in forum Qt Programming
    Replies: 0
    Last Post: 23rd March 2010, 06:43
  3. Shell command from Qt 4.5.2 by QProcess
    By Rajeshsan in forum Newbie
    Replies: 5
    Last Post: 21st December 2009, 17:03
  4. QProcess & linux shell characters
    By Ti_Thom in forum Qt Programming
    Replies: 4
    Last Post: 21st December 2009, 11:01
  5. qprocess and shell
    By GuL in forum Qt Programming
    Replies: 1
    Last Post: 12th February 2009, 06:47

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.