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. Qt installer framework execute command

Qt installer framework execute command

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.6k Views
  • 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.
  • G Offline
    G Offline
    GregB
    wrote on last edited by
    #1

    I'm writing an installer that copies files, but also installs yum packages and performs some mysql database commands. I've used the Execute command in the qt installer to run commands like the following:

    component.addElevatedOperation("Execute", "{0,100}", "yum", "install", "-y", "mariadb");
    component.addElevatedOperation("Execute", "{0}", "systemctl", "restart", "httpd.service");
    

    They run just fine, installing packages and enabling system services. When I try to run a mysql command, it doesn't work, and just exits with a code 1.

    component.addElevatedOperation("Execute", "{0}", "mysql", "-uroot", "-ppassword", "dbname", "<", "/db/db.sql");
    

    By the time the previous command is run, the mysql database is installed and running (this is done in a previous installer module). Running this command from the command works fine, though and exits with code 0.

    mysql -uroot -ppassword dbname < /db/db.sql
    

    What is different about the Execute from within Qt installer than running it from the command line?

    sierdzioS 1 Reply Last reply
    0
    • G GregB

      I'm writing an installer that copies files, but also installs yum packages and performs some mysql database commands. I've used the Execute command in the qt installer to run commands like the following:

      component.addElevatedOperation("Execute", "{0,100}", "yum", "install", "-y", "mariadb");
      component.addElevatedOperation("Execute", "{0}", "systemctl", "restart", "httpd.service");
      

      They run just fine, installing packages and enabling system services. When I try to run a mysql command, it doesn't work, and just exits with a code 1.

      component.addElevatedOperation("Execute", "{0}", "mysql", "-uroot", "-ppassword", "dbname", "<", "/db/db.sql");
      

      By the time the previous command is run, the mysql database is installed and running (this is done in a previous installer module). Running this command from the command works fine, though and exits with code 0.

      mysql -uroot -ppassword dbname < /db/db.sql
      

      What is different about the Execute from within Qt installer than running it from the command line?

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @GregB said in Qt installer framework execute command:

      <

      This is different. QProcess does not spawn a full shell, it only executes a single process. So pipes, redirection etc. do not work.

      There are ways around, probably the easiest is to move that line into a script and call it via something like (pseudo code, not tested):

      component.addElevatedOperation("Execute", "{0}", "bash", "-c", "script.sh");
      

      (Z(:^

      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