191 const char *remotehost,
192 const char *remotedir,
193 const char *remoteexe,
198 const char *serverhost = gSystem->HostName();
199 const char *sdisplay = gSystem->Getenv(
"DISPLAY");
201 const char *rootsys = gSystem->Getenv(
"ROOTSYS");
202 const char *path = gSystem->Getenv(
"PATH");
203 const char *ldpath = gSystem->Getenv(
"LD_LIBRARY_PATH");
205 if (!name || (strlen(name) == 0)) name =
"UserAnalysis";
206 if (!serverhost || (strlen(serverhost) == 0)) serverhost =
"localhost";
208 if (!gSystem->Getenv(
"GO4OLDLAUNCH")) {
211 const char *shellname =
"exec";
214 else if (shellkind == 2)
215 shellname = konsole == 1 ?
"ssh" :
"sshX";
216 prefs.
SetPar(
"shellkind", shellname,
false);
217 prefs.
SetPar(
"exekind", TString::Format(
"%d", exe_kind).Data(),
false);
218 prefs.
SetPar(
"clientkind", serverkind > 0 ?
"Go4Server" :
"Go4Client",
false);
220 prefs.
AddFile(
"go4.prefs",
false);
223 std::cout <<
"Cannot find prefs file" << std::endl;
227 prefs.
SetPar(
"guihost", serverhost,
false);
229 prefs.
SetPar(
"guiport", TString::Format(
"%d", guiport).Data());
230 prefs.
SetPar(
"guigo4sys", go4sys,
false);
231 prefs.
SetPar(
"analysisname", name,
false);
232 prefs.
SetPar(
"workdir", remotedir,
false);
233 prefs.
SetPar(exe_kind == 0 ?
"exename" :
"libname", remoteexe,
false);
235 if ((exe_kind == 1) && exeargs && (strlen(exeargs) > 0))
236 prefs.
SetPar(
"userargs", exeargs,
false);
238 prefs.
SetPar(
"userargs",
"",
false);
240 const char *termname =
"qtwindow";
243 else if (konsole == 3)
244 termname =
"konsole";
247 if ((shellkind == 0) && (konsole == 1))
248 prefs.
SetPar(
"cd_workdir",
"");
250 std::string executable;
251 bool is_exe = prefs.
GetOpt(
"exekind") !=
"1";
253 if (prefs.
GetOpt(
"exename").empty())
254 executable = prefs.
GetOpt(
"analysis_default_exe");
256 executable = prefs.
GetOpt(
"analysis_exe");
258 if (prefs.
GetOpt(
"libname").empty())
259 executable = prefs.
GetOpt(
"analysis_default_lib");
261 executable = prefs.
GetOpt(
"analysis_lib");
263 prefs.
SetPar(
"analysis", executable.c_str());
266 prefs.
SetPar(
"killexename",
"go4analysis",
false);
273 const char *runname = strrchr(remoteexe, symbol);
274 prefs.
SetPar(
"killexename", runname ? runname + 1 : remoteexe,
false);
277 std::string initcmd = prefs.
GetOpt(shellkind == 0 ?
"execinitcmd" :
"shellinitcmd");
278 prefs.
SetPar(
"initcmd", initcmd.c_str());
280 std::string progcmd = prefs.
GetOpt((serverkind>0) ? ((serverkind==2) ?
"httpcmd" :
"servercmd") :
"clientcmd");
281 prefs.
SetPar(
"progcmd", progcmd.c_str());
283 std::string hostcmd = prefs.
GetOpt(termname);
284 prefs.
SetPar(
"hostcmd", hostcmd.c_str());
286 std::string cmd = prefs.
GetOpt(shellname);
287 std::cout <<
"cmd: " << cmd << std::endl;
288 launchcmd = cmd.c_str();
290 std::string dkill = prefs.
GetOpt(
"kill");
291 prefs.
SetPar(
"hostcmd", dkill.c_str());
292 cmd = prefs.
GetOpt(shellname);
293 std::cout <<
"killcmd: " << cmd << std::endl;
294 killcmd = cmd.c_str();
299 if (!go4sys || (strlen(go4sys) == 0))
return kFALSE;
303 std::ifstream launchprefs(filename.Data());
305 TGo4Log::Debug(
"Master -- ERROR: Preferences file %s not existing, could not launch client ",
310 char formatstring[1000];
312 if ((konsole<1) || (konsole>3)) konsole = 1;
314 if (serverkind>0) num+=3;
316 for (
int n = 0; n < num; n++)
317 launchprefs.getline(formatstring, 1000,
'\n');
319 const char *sh_com =
"";
320 const char *sh_host = remotehost;
321 TString serverdisplay =
"";
326 serverdisplay =
"-display ";
327 serverdisplay += sdisplay;
330 sh_com = (konsole == 0) ?
"ssh -x " :
"ssh -X ";
338 killcmd =
"killall ";
339 killcmd += remoteexe;
341 if((shellkind > 0) && (strcmp(remotehost, gSystem->HostName()) != 0) && (strcmp(remotehost,
"localhost") != 0)) {
342 TString precmd = sh_com;
344 precmd += remotehost;
346 killcmd.Prepend(precmd);
353 launchcmd.Form(formatstring,
354 sh_com, sh_host, serverdisplay.Data(), name, remotehost, go4sys, go4sys, rootsys,
355 path, ldpath, remotedir, remoteexe, name, serverhost, guiport, remotehost);
360 launchcmd.Form(formatstring,
361 sh_com, sh_host, name, go4sys, go4sys, rootsys,
362 path, ldpath, remotedir, remoteexe, name, serverhost, guiport, remotehost);
368 launchcmd.Form(formatstring,
369 sh_com, sh_host, go4sys, go4sys, rootsys,
370 path, ldpath, remotedir, remoteexe, name, serverhost, guiport, remotehost);
static Bool_t GetLaunchString(TString &launchcmd, TString &killcmd, Int_t serverkind, Int_t shellkind, Int_t konsole, const char *name, const char *remotehost, const char *remotedir, const char *remoteexe, Int_t guiport, Int_t exe_kind=0, const char *exeargs=nullptr)