| OpendTect 8.0

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
OS::MachineCommand Class Reference
Basic

Encapsulates an actual command to execute + the machine to run it on. More...

`#include <oscommand.h>`

## Public Member Functions
| MachineCommand (const char *prognm, bool isolated)
| MachineCommand (const char *prognm, const BufferStringSet &arguments)
| MachineCommand (const char *prognm, const char *arg1, const char *arg2=0, const char *arg3=0, const char *arg4=0, const char *arg5=0)
| MachineCommand (const char *prognm=nullptr)
| MachineCommand (const MachineCommand &, bool isolated)
MachineCommand & | addArg (const char *)
template<class T >
MachineCommand & | addArg (const T &t)
MachineCommand & | addArgs (const BufferStringSet &)
MachineCommand & | addFileRedirect (const char *fnm, int stdcode=0, bool append=false)
MachineCommand & | addFlag (const char *flg, KeyStyle ks=NewStyle)
MachineCommand & | addKeyedArg (const char *ky, const char *valstr, KeyStyle ks=NewStyle)
template<class T >
MachineCommand & | addKeyedArg (const char *ky, const T &t, KeyStyle ks=NewStyle)
MachineCommand & | addPipe ()
const BufferStringSet & | args () const
bool | execute (BufferString &output_stdout, BufferString *output_stderr=nullptr, const char *workdir=nullptr)
| run &, wait until finished, catch output
bool | execute (const CommandExecPars &)
bool | execute (LaunchType lt=Wait4Finish, const char *workdir=nullptr)
bool | hasHostName () const
bool | hostIsWindows () const
const char * | hostName () const
bool | isBad () const
const char * | program () const
const char * | remExec () const
BufferString | runAndCollectOutput (BufferString *errmsg=nullptr)
| for quick get-me-the-output-of-this-command
MachineCommand & | setHostIsWindows (bool yn)
MachineCommand & | setHostName (const char *)
MachineCommand & | setProgram (const char *pn)
MachineCommand & | setRemExec (const char *sh)
BufferString | toString (const CommandExecPars *=nullptr) const
| Only for messaging purposes.

## Static Public Member Functions
static const char * | defaultRemExec ()
static const char * | getIsolationScriptFnm ()
static const char * | odRemExecCmd ()
static void | setDefaultRemExec (const char *s)
static void | setIsolationScript (const char *)
static const char * | sKeyIsolationScript ()
static const char * | sKeyJobID ()
static const char * | sKeyMasterHost ()
static const char * | sKeyMasterPort ()
static const char * | sKeyPrimaryHost ()
static const char * | sKeyPrimaryPort ()
static const char * | sKeyRemoteCmd ()
static const char * | sKeyRemoteHost ()

## Private Member Functions
void | addShellIfNeeded ()
MachineCommand | getExecCommand (const CommandExecPars *=nullptr) const
void | setIsolated (const char *prognm)

## Private Attributes
BufferStringSet | args_
BufferString | hname_
bool | hostiswin_ = false
bool | needshell_ = false
BufferString | prognm_
BufferString | remexec_ = defremexec_

## Static Private Attributes
static BufferString | defremexec_

## Friends
class | ::StreamProvider
class | CommandLauncher

## Detailed Description

Encapsulates an actual command to execute + the machine to run it on.

The default remote execution command is ssh.

<>

## Constructor & Destructor Documentation

## ◆ MachineCommand() [1/5]

OS::MachineCommand::MachineCommand | ( | const char * | prognm = nullptr | ) |
| inline

## ◆ MachineCommand() [2/5]

OS::MachineCommand::MachineCommand | ( | const char * | prognm,
|  | const BufferStringSet & | arguments )
| inline

## ◆ MachineCommand() [3/5]

OS::MachineCommand::MachineCommand | ( | const char * | prognm,
|  | const char * | arg1,
|  | const char * | arg2 = 0,
|  | const char * | arg3 = 0,
|  | const char * | arg4 = 0,
|  | const char * | arg5 = 0 )

## ◆ MachineCommand() [4/5]

OS::MachineCommand::MachineCommand | ( | const char * | prognm,
|  | bool | isolated )

## ◆ MachineCommand() [5/5]

OS::MachineCommand::MachineCommand | ( | const MachineCommand & | ,
|  | bool | isolated )

## Member Function Documentation

## ◆ addArg() [1/2]

MachineCommand & OS::MachineCommand::addArg | ( | const char * |  | ) |

## ◆ addArg() [2/2]

template<class T >

MachineCommand & OS::MachineCommand::addArg | ( | const T & | t | ) |
| inline

## ◆ addArgs()

MachineCommand & OS::MachineCommand::addArgs | ( | const BufferStringSet & |  | ) |

## ◆ addFileRedirect()

MachineCommand & OS::MachineCommand::addFileRedirect | ( | const char * | fnm,
|  | int | stdcode = 0,
|  | bool | append = false )

stdcode=0: '>'; stdcode=1: '1>'; stdcode=2: '2>' stdcode=3: '> fnm 2>&1'; append: '>>'; otherwise: '>'

## ◆ addFlag()

MachineCommand & OS::MachineCommand::addFlag | ( | const char * | flg,
|  | KeyStyle | ks = NewStyle )
| inline

## ◆ addKeyedArg() [1/2]

MachineCommand & OS::MachineCommand::addKeyedArg | ( | const char * | ky,
|  | const char * | valstr,
|  | KeyStyle | ks = NewStyle )

## ◆ addKeyedArg() [2/2]

template<class T >

MachineCommand & OS::MachineCommand::addKeyedArg | ( | const char * | ky,
|  | const T & | t,
|  | KeyStyle | ks = NewStyle )
| inline

## ◆ addPipe()

MachineCommand & OS::MachineCommand::addPipe | ( |  | ) |
| inline

## ◆ addShellIfNeeded()

void OS::MachineCommand::addShellIfNeeded | ( |  | ) |
| private

Analyses the cmd and looks for pipes or redirects. If these are found, the cmd is converted to a shell command.

## ◆ args()

const BufferStringSet & OS::MachineCommand::args | ( |  | ) | const
| inline

## ◆ defaultRemExec()

static const char * OS::MachineCommand::defaultRemExec | ( |  | ) |
| inline static

## ◆ execute() [1/3]

bool OS::MachineCommand::execute | ( | BufferString & | output_stdout,
|  | BufferString * | output_stderr = nullptr,
|  | const char * | workdir = nullptr )

run &, wait until finished, catch output

## ◆ execute() [2/3]

bool OS::MachineCommand::execute | ( | const CommandExecPars & |  | ) |

## ◆ execute() [3/3]

bool OS::MachineCommand::execute | ( | LaunchType | lt = Wait4Finish,
|  | const char * | workdir = nullptr )

## ◆ getExecCommand()

MachineCommand OS::MachineCommand::getExecCommand | ( | const CommandExecPars * | = nullptr | ) | const
| private

## ◆ getIsolationScriptFnm()

static const char * OS::MachineCommand::getIsolationScriptFnm | ( |  | ) |
| static

## ◆ hasHostName()

bool OS::MachineCommand::hasHostName | ( |  | ) | const
| inline

## ◆ hostIsWindows()

bool OS::MachineCommand::hostIsWindows | ( |  | ) | const
| inline

## ◆ hostName()

const char * OS::MachineCommand::hostName | ( |  | ) | const
| inline

## ◆ isBad()

bool OS::MachineCommand::isBad | ( |  | ) | const
| inline

## ◆ odRemExecCmd()

static const char * OS::MachineCommand::odRemExecCmd | ( |  | ) |
| inline static

## ◆ program()

const char * OS::MachineCommand::program | ( |  | ) | const
| inline

## ◆ remExec()

const char * OS::MachineCommand::remExec | ( |  | ) | const
| inline

## ◆ runAndCollectOutput()

BufferString OS::MachineCommand::runAndCollectOutput | ( | BufferString * | errmsg = nullptr | ) |

for quick get-me-the-output-of-this-command

## ◆ setDefaultRemExec()

static void OS::MachineCommand::setDefaultRemExec | ( | const char * | s | ) |
| inline static

## ◆ setHostIsWindows()

MachineCommand & OS::MachineCommand::setHostIsWindows | ( | bool | yn | ) |

## ◆ setHostName()

MachineCommand & OS::MachineCommand::setHostName | ( | const char * |  | ) |

## ◆ setIsolated()

void OS::MachineCommand::setIsolated | ( | const char * | prognm | ) |
| private

## ◆ setIsolationScript()

static void OS::MachineCommand::setIsolationScript | ( | const char * |  | ) |
| static

## ◆ setProgram()

MachineCommand & OS::MachineCommand::setProgram | ( | const char * | pn | ) |
| inline

## ◆ setRemExec()

MachineCommand & OS::MachineCommand::setRemExec | ( | const char * | sh | ) |

## ◆ sKeyIsolationScript()

static const char * OS::MachineCommand::sKeyIsolationScript | ( |  | ) |
| inline static

## ◆ sKeyJobID()

static const char * OS::MachineCommand::sKeyJobID | ( |  | ) |
| inline static

## ◆ sKeyMasterHost()

static const char * OS::MachineCommand::sKeyMasterHost | ( |  | ) |
| inline static

## ◆ sKeyMasterPort()

static const char * OS::MachineCommand::sKeyMasterPort | ( |  | ) |
| inline static

## ◆ sKeyPrimaryHost()

static const char * OS::MachineCommand::sKeyPrimaryHost | ( |  | ) |
| inline static

## ◆ sKeyPrimaryPort()

static const char * OS::MachineCommand::sKeyPrimaryPort | ( |  | ) |
| inline static

## ◆ sKeyRemoteCmd()

static const char * OS::MachineCommand::sKeyRemoteCmd | ( |  | ) |
| inline static

## ◆ sKeyRemoteHost()

static const char * OS::MachineCommand::sKeyRemoteHost | ( |  | ) |
| inline static

## ◆ toString()

BufferString OS::MachineCommand::toString | ( | const CommandExecPars * | = nullptr | ) | const

Only for messaging purposes.

## Friends And Related Symbol Documentation

## ◆ ::StreamProvider

friend class ::StreamProvider
| friend

## ◆ CommandLauncher

friend class CommandLauncher
| friend

## Member Data Documentation

## ◆ args_

BufferStringSet OS::MachineCommand::args_
| private

## ◆ defremexec_

BufferString OS::MachineCommand::defremexec_
| static private

## ◆ hname_

BufferString OS::MachineCommand::hname_
| private

## ◆ hostiswin_

bool OS::MachineCommand::hostiswin_ = false
| private

## ◆ needshell_

bool OS::MachineCommand::needshell_ = false
| private

## ◆ prognm_

BufferString OS::MachineCommand::prognm_
| private

## ◆ remexec_

BufferString OS::MachineCommand::remexec_ = defremexec_
| private

Generated at
for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2025