Search code examples
qt4mysqlqprocess

Can't launch correctly mysqldump in QProcess of Qt4


i'm trying to download sql dump from distant host in Qt4 application (Debian 6).

QProcess process_one(this), process_two(this);
    QStringList args1, args2;
    args1 << "--host=192.168.0.1" << "--user=root" << "--password=root" << "nfc tag";
    args2 << "--user=root" << "--password=8KQ90fV9" << "nfc_sink";
    process_one.setStandardOutputFile("/home/Volchok/nfc.sql");
    //process_two.setStandardInputFile("/home/Volchok/nfc.sql");
    process_one.start("mysqldump", args1);
    while(!process_one.waitForFinished(-1));
    if (process_one.exitStatus()){
        std::cout << "Control Window: error with mysqldump process\n";
        return;
    }
    qDebug()<< "error in mysqldump process: " << process_one.error();
    /*process_two.start("mysql", args2);
    while(!process_two.waitForFinished());
    if (process_two.exitStatus()){
        std::cout << "Control Window: error with mysql process\n";
        return;
    }
    qDebug()<< "error in mysql process: " << process_two.error();*/

Application launches mysqldump, which creates nfc.sql file, but it's empty!

-- MySQL dump 10.13  Distrib 5.1.49, for debian-linux-gnu (i486)
--
-- Host: 192.168.0.1    Database: nfc tag
-- ------------------------------------------------------
-- Server version   5.5.43-0+deb7u1

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

The same command line in terminal works ok. nfc.sql file gets much more data. QProcess ends with code 5. Distant host - Raspberry Pi B+. Why qprocess doesn't work correctly? What am i doing wrong?


Solution

  • The problem was in

    args1 << "--host=192.168.0.1" << "--user=root" << "--password=root" << "nfc tag";
    

    It should be

    args1 << "--host=192.168.0.1" << "--user=root" << "--password=root" << "nfc" << "tag";