Subject | Re: [ib-support] Backups |
---|---|
Author | Brad Pepers |
Post date | 2001-06-07T02:51:29Z |
On Wednesday 06 June 2001 09:25, Andy Canfield wrote:
program and also on the backup filename. Also the database was often remote
so it would be "system:path". With all this, the command was too long and
using system() on the command would fail.
I found a way around it by using CreateProcess directly. This doesn't seem
to have the same problems with command line lengths and I can wait for the
child to complete and get the result code so it works really well! Here is
the code BTW:
SetEnvironmentVariable("ISC_USER", "SYSDBA");
SetEnvironmentVariable("ISC_PASSWORD", "masterkey");
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
// Start the child process.
char cmd[4096];
strcpy(cmd, QDir::convertSeparators(command));
if (CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
SetEnvironmentVariable("ISC_USER", "");
SetEnvironmentVariable("ISC_PASSWORD", "");
The string "command" has the full command line and the
QDir::convertSeparators is just a Qt library issue. The use of the ISC_
environment variables rather than passing it on the command line is just a
hold over from trying to reduce the command line length in the system() case
and I could likely just include the username/password in the command line
instead.
CreateProcess and found it fairly easy to use and it provides all the
functionality I wanted so I can avoid the whole batch file issue!
--
Brad Pepers
brad@...
> My (working) command line under Windows 98 SE:The problem I ended up with is that I needed the full path on the gbak
> gbak -B -USER SYSDBA -PASSWORD masterkey -VERIFY D:\Database\OOP.GDB
> OOP.GBK -B means backup
> -USER SYSDBA (that's who owns the database)
> -PASSWORD masterkey (it maybe has to be included on the command line
> -VERIFY (I forget why but it sounds nice)
> D:\Database\OOP.GDB = the database name. I suspect that gbak.exe must run
> on the machine where the database is. OOP.GBK = the name of the output
> backup file.
program and also on the backup filename. Also the database was often remote
so it would be "system:path". With all this, the command was too long and
using system() on the command would fail.
I found a way around it by using CreateProcess directly. This doesn't seem
to have the same problems with command line lengths and I can wait for the
child to complete and get the result code so it works really well! Here is
the code BTW:
SetEnvironmentVariable("ISC_USER", "SYSDBA");
SetEnvironmentVariable("ISC_PASSWORD", "masterkey");
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
// Start the child process.
char cmd[4096];
strcpy(cmd, QDir::convertSeparators(command));
if (CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
SetEnvironmentVariable("ISC_USER", "");
SetEnvironmentVariable("ISC_PASSWORD", "");
The string "command" has the full command line and the
QDir::convertSeparators is just a Qt library issue. The use of the ISC_
environment variables rather than passing it on the command line is just a
hold over from trying to reduce the command line length in the system() case
and I could likely just include the username/password in the command line
instead.
> If I create any batch file in Windows 98, I right-click on it and setThanks for the info. Happily I finally found the documentation of
> properties Memory to Auto + Protected and Initial Environment to 2048; the
> default "Auto" never worked for me. Yeah, the default behavior screws up;
> but the default behavior of Microsoft is to screw up; like coders like
> code.
>
> You write "I then instead wrote out a batch file. In it I set ISC_USER and
> ISC_PASSWORD and then call gbak. The problem with this is that it pops up
> a MSDOS window showing the command running (and the password in plain
> text!) ". You can hide it like this: @echo off
> gbak -B -USER SYSDBA -PASSWORD masterkey -etc
> and it won't appear on the screen. But you will still have an ASCII text
> file on the hard disk containing the password in plain text. An alternative
> is to use a DOS program I have (write to andy@... and I'll send
> you a copy) that will take a string from the keyboard and put it in an
> environment variable. While you're typing it will appear on the screen but
> it can then be erased like this: @echo off
> set U=SYSDBA
> getkey /s Password for %U%?
> cls
> gbak -B -USER %U% -PASSWORD %GETKEY% -etc.
> set GETKEY=
>
> Hope that helps.
CreateProcess and found it fairly easy to use and it provides all the
functionality I wanted so I can avoid the whole batch file issue!
--
Brad Pepers
brad@...