procedure TGUI.loadErrors;
var
sLogPath:
String;
p1 :
String;
stream: TStream;
begin
sLogPath := GetCurrentDir;
p1 := sLogPath + '
\logs\' + '
error.log';
self.downloadFile(p1, '
/var/log/nginx/error.log');
//sollte aus einer config kommen, da unterschiedlich je nach OS
stream := TFileStream.Create(p1, fmOpenRead
or fmShareDenyNone);
try
Memo2.Lines.LoadFromStream(stream);
finally
stream.Free;
end;
end;
//http://www.delphipraxis.net/98541-warten-bis-aufgerufener-prozess-beendet-ist.html
procedure TGUI.ShellExecAndWait(dateiname:
string; Parameter:
string);
var executeInfo: TShellExecuteInfo;
dw: DWORD;
begin
FillChar(executeInfo, SizeOf(executeInfo), 0);
with executeInfo
do begin
cbSize := SizeOf(executeInfo);
fMask := SEE_MASK_NOCLOSEPROCESS
or SEE_MASK_FLAG_DDEWAIT;
Wnd := GetActiveWindow();
executeInfo.lpVerb := '
open';
executeInfo.lpParameters := PChar(Parameter);
lpFile := PChar(dateiname);
nShow := SW_SHOWNORMAL;
end;
if ShellExecuteEx(@executeInfo)
then dw := executeInfo.HProcess
else begin
ShowMessage('
Fehler: ' + SysErrorMessage(GetLastError));
Exit;
end;
while WaitForSingleObject(executeInfo.hProcess, 50) <> WAIT_OBJECT_0
do
Application.ProcessMessages;
CloseHandle(dw);
end;
procedure TGUI.downloadFile(pathLocal:
String; pathRemote:
String)
var
pscpCmdLineBase:
String;
begin
pscpCmdLineBase := '
-P 1234 -i .\schlüsseldatei.ppk username@example.com:%s .\%s ';
//das hier sollte natürlich aus einer Config-Datei oder Benutzereingabe stammen
self.ShellExecAndWait('
pscp.exe', Format(pscpCmdLineBase, [pathRemote, pathLocal]));
//pscp.exe ins verzeichnis legen
end;