Results 1 to 8 of 8

Thread: To pass a value as response to linux command using QT

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2014
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default To pass a value as response to linux command using QT

    Hi all,
    I am designing an application using QT for an embedded device and I got stuck in an issue. I can able to pass the linux command using system() function. For a particular command I need to enter the password dynamically in the application window. Please help me to send the value for the previous executed command, dynamically using QT application.

    Thanks in advance....

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: To pass a value as response to linux command using QT

    I am not sure what you mean, but if you need more control over the external command, have a look at QProcess instead of system()

    Cheers,
    _

  3. #3
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: To pass a value as response to linux command using QT

    I think what chillin means is something like:
    Qt Code:
    1. su -c "fdisk -l"
    To copy to clipboard, switch view to plain text mode 

    A command like this will ask for a password ...

  4. #4
    Join Date
    Feb 2014
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: To pass a value as response to linux command using QT

    yes graciano you are correct.

    I will explain the issue bit clearly.
    I am developing an application in which I will run some commands using system() function, which may request password for commands with "sudo" and "ssh", in that case I need to pass the password as a string to response the command which will be waiting to get the password as input. I need help (with example code) to pass the password to the commands which are executed using the system() function.

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: To pass a value as response to linux command using QT

    Well, if you insist on using the system function, then you are out of luck.

    Cheers,
    _

  6. #6
    Join Date
    Feb 2014
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: To pass a value as response to linux command using QT

    Please let me know (with scratch code) if any other function other than system() performs the same task.

    Thank you in advance.

  7. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: To pass a value as response to linux command using QT

    I suggest reading the replies then.
    Comment #2 might be a good start.

    Cheers,
    _

  8. #8
    Join Date
    Oct 2010
    Location
    Tijuana, Baja California, México
    Posts
    19
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: To pass a value as response to linux command using QT

    I'm using linux and there's a reason about asking for a password...I read about echoing:

    echo -e "tadaaa" | sudo -S format all

    but, I prefer the asking annoy

Similar Threads

  1. Best way to pass data between Windows and Linux
    By deepakn in forum General Programming
    Replies: 1
    Last Post: 28th December 2011, 12:40
  2. Executing linux command as root
    By stefan in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2011, 15:07
  3. Replies: 1
    Last Post: 17th May 2010, 16:15
  4. make[2]:arm-linux-g++:Command not found.(Greenphone SDK)
    By rishiraj in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 17th April 2009, 13:57
  5. Linux/Bash: Run a command as another user
    By sunil.thaha in forum General Discussion
    Replies: 1
    Last Post: 5th December 2006, 09:49

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
  •  
Qt is a trademark of The Qt Company.