This is my entire code. I seams pg_dump received all my parameters, but something was missed and it returned error. Note that I am using the full path of to pg_dump. Yhis _database objectc gives the all information about the database I want to backup :
string host = _database->host().empty() ? "localhost" : _database->host();
int port = _database->portNumber() == 0 ? 5432 : _database->portNumber();
string path = "C:\\Arquivos de programas\\PostgreSQL\\8.2\\bin";
string backupExe = "\"" + path + "\\pg_dump.exe\"";
string fileName = string(fileLineEdit->text().latin1());
string envPassword = "PGPASSWORD=" + _database->password();
if(!_process)
{
connect(_process, SIGNAL(readyReadStdout()), this, SLOT(readFromStdout()));
connect(_process, SIGNAL(readyReadStderr()), this, SLOT(readFromStderr()));
}
_process->setWorkingDirectory(dir);
_process->clearArguments();
_process->addArgument(backupExe.c_str());
_process->addArgument("-i");
_process->addArgument("-h");
_process->addArgument(host.c_str());
_process->addArgument("-p");
_process->addArgument(Te2String(port).c_str());
_process->addArgument("-U");
_process->addArgument(_database->user().c_str());
_process->addArgument("-Fc");
_process->addArgument("-b");
_process->addArgument("-v");
_process->addArgument("-f");
_process->addArgument(fileName.c_str());
_process->addArgument(_database->databaseName().c_str());
strList->append(envPassword.c_str());
if(!_process->start(strList))
{
QMessageBox::information(this,
"Information",
"Error starting process");
}
string host = _database->host().empty() ? "localhost" : _database->host();
int port = _database->portNumber() == 0 ? 5432 : _database->portNumber();
string path = "C:\\Arquivos de programas\\PostgreSQL\\8.2\\bin";
string backupExe = "\"" + path + "\\pg_dump.exe\"";
string fileName = string(fileLineEdit->text().latin1());
string envPassword = "PGPASSWORD=" + _database->password();
if(!_process)
{
_process = new QProcess(0);
connect(_process, SIGNAL(readyReadStdout()), this, SLOT(readFromStdout()));
connect(_process, SIGNAL(readyReadStderr()), this, SLOT(readFromStderr()));
}
QDir dir(path.c_str());
_process->setWorkingDirectory(dir);
_process->clearArguments();
_process->addArgument(backupExe.c_str());
_process->addArgument("-i");
_process->addArgument("-h");
_process->addArgument(host.c_str());
_process->addArgument("-p");
_process->addArgument(Te2String(port).c_str());
_process->addArgument("-U");
_process->addArgument(_database->user().c_str());
_process->addArgument("-Fc");
_process->addArgument("-b");
_process->addArgument("-v");
_process->addArgument("-f");
_process->addArgument(fileName.c_str());
_process->addArgument(_database->databaseName().c_str());
QStringList* strList = new QStringList();
strList->append(envPassword.c_str());
if(!_process->start(strList))
{
QMessageBox::information(this, "Information", "Error starting process");
}
To copy to clipboard, switch view to plain text mode
Thanks
--------------------------------------------------------------------------------
Obs: I am using QT 3.2.0
Bookmarks