Unsolved Qt installer framework execute command
-
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?
-
@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");