Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProcess is not running for some programs in linux..
Forum Updated to NodeBB v4.3 + New Features

QProcess is not running for some programs in linux..

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 782 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • xenovasX Offline
    xenovasX Offline
    xenovas
    wrote on last edited by xenovas
    #1

    Hello ,

    i'm using the following snippet and it doesn't work.. Does someone experience the same issue ? the rm command works as expected.. Also process.errorString() returns "unknown error"

    QProcess process; 
    const QString sed = "/usr/bin/sed" ; 
    const QString ed = "'s/"+esc_username+":.*$//'"; 
    const Qstring option = "-i"; 
    const QString shadowpath = "/etc/shadow"; 
    QStringList arguments ; 
    
    arguments << option << ed << shadowpath ;
    
    process.start(sed, arguments); 
    process.waitForStarted(); 
    process.waitForFinished(); 
    
    arguments.clear(); 
    

    @xen0vas

    JonBJ 1 Reply Last reply
    0
    • xenovasX xenovas

      Hello ,

      i'm using the following snippet and it doesn't work.. Does someone experience the same issue ? the rm command works as expected.. Also process.errorString() returns "unknown error"

      QProcess process; 
      const QString sed = "/usr/bin/sed" ; 
      const QString ed = "'s/"+esc_username+":.*$//'"; 
      const Qstring option = "-i"; 
      const QString shadowpath = "/etc/shadow"; 
      QStringList arguments ; 
      
      arguments << option << ed << shadowpath ;
      
      process.start(sed, arguments); 
      process.waitForStarted(); 
      process.waitForFinished(); 
      
      arguments.clear(); 
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @xenovas

      and it doesn't work.

      Put in error handling for all QProcess code, including reading any standard error output.

      For a start, the sed could find your esc_username content unacceptable. What is in it when it goes wrong?

      1 Reply Last reply
      1
      • Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @xenovas said in QProcess is not running for some programs in linux..:

        const QString ed = "'s/"+esc_username+":.*$//'";

        The single quotes are wrong

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        JonBJ 1 Reply Last reply
        4
        • Christian EhrlicherC Christian Ehrlicher

          @xenovas said in QProcess is not running for some programs in linux..:

          const QString ed = "'s/"+esc_username+":.*$//'";

          The single quotes are wrong

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @Christian-Ehrlicher

          The single quotes are wrong

          Indeed. It might help the OP if you commented that they should not be there at all! :)

          1 Reply Last reply
          0
          • xenovasX Offline
            xenovasX Offline
            xenovas
            wrote on last edited by
            #5

            @Christian-Ehrlicher @JonB hmm.. same problem again and again.. -- tha quotes -- .. thanks guys :)

            @xen0vas

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              Unless you run it as root, it won't work because the file you are trying to modify is not accessible to standard users.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              xenovasX 1 Reply Last reply
              2
              • SGaistS SGaist

                Hi,

                Unless you run it as root, it won't work because the file you are trying to modify is not accessible to standard users.

                xenovasX Offline
                xenovasX Offline
                xenovas
                wrote on last edited by
                #7

                @SGaist it runs with root privs thanks

                @xen0vas

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved