Streaming of input and output from Linux command.
More...
#include <JProcess.hh>
|
void | execute (const char *path, const char *arg0, const char *arg1=(char *) NULL, const char *arg2=(char *) NULL, const char *arg3=(char *) NULL, const char *arg4=(char *) NULL, const char *arg5=(char *) NULL, const char *arg6=(char *) NULL, const char *arg7=(char *) NULL, const char *arg8=(char *) NULL, const char *arg9=(char *) NULL) |
| Execute command. More...
|
|
Streaming of input and output from Linux command.
Definition at line 29 of file JProcess.hh.
◆ JProcess() [1/2]
JSYSTEM::JProcess::JProcess |
( |
| ) |
|
|
inline |
Default constructor.
This constructor starts an interactive shell.
Definition at line 36 of file JProcess.hh.
44 execute(
"/bin/tcsh",
"tcsh",
"-i",
"-f");
◆ JProcess() [2/2]
JSYSTEM::JProcess::JProcess |
( |
const std::string & |
command | ) |
|
|
inline |
Constructor.
- Parameters
-
Definition at line 53 of file JProcess.hh.
61 execute(
"/bin/tcsh",
"tcsh",
"-f",
"-c", command.c_str());
◆ ~JProcess()
JSYSTEM::JProcess::~JProcess |
( |
| ) |
|
|
inline |
◆ getInputStreamBuffer()
Get pointer to input stream buffer connected to the normal output stream.
- Parameters
-
size | size of internal buffers |
- Returns
- pointer input stream buffer
Definition at line 86 of file JProcess.hh.
89 gOut =
new JFileInputStreamBuffer(
out, size);
◆ getErrorStreamBuffer()
Get pointer to input stream buffer connected to the error output stream.
- Parameters
-
size | size of internal buffers |
- Returns
- pointer to input stream buffer
Definition at line 102 of file JProcess.hh.
105 gErr =
new JFileInputStreamBuffer(
err, size);
◆ getOutputStreamBuffer()
Get pointer to output stream buffer connected to the normal input stream.
- Parameters
-
size | size of internal buffers |
- Returns
- pointer to output stream buffer
Definition at line 118 of file JProcess.hh.
121 gIn =
new JFileOutputStreamBuffer(
in, size);
◆ execute()
void JSYSTEM::JProcess::execute |
( |
const char * |
path, |
|
|
const char * |
arg0, |
|
|
const char * |
arg1 = (char*) NULL , |
|
|
const char * |
arg2 = (char*) NULL , |
|
|
const char * |
arg3 = (char*) NULL , |
|
|
const char * |
arg4 = (char*) NULL , |
|
|
const char * |
arg5 = (char*) NULL , |
|
|
const char * |
arg6 = (char*) NULL , |
|
|
const char * |
arg7 = (char*) NULL , |
|
|
const char * |
arg8 = (char*) NULL , |
|
|
const char * |
arg9 = (char*) NULL |
|
) |
| |
|
inlineprotected |
Execute command.
- Parameters
-
path | path |
arg0 | comma separted argument list |
arg1 | comma separted argument list |
arg2 | comma separted argument list |
arg3 | comma separted argument list |
arg4 | comma separted argument list |
arg5 | comma separted argument list |
arg6 | comma separted argument list |
arg7 | comma separted argument list |
arg8 | comma separted argument list |
arg9 | comma separted argument list |
Definition at line 143 of file JProcess.hh.
159 if (pipe(pipe_stdin)) {
throw JPipeOpenException(
"Error at pipe of standard input."); }
160 if (pipe(pipe_stdout)) {
throw JPipeOpenException(
"Error at pipe of standard output."); }
161 if (pipe(pipe_stderr)) {
throw JPipeOpenException(
"Error at pipe of standard error."); }
163 const pid_t pid = fork();
169 throw JForkException(
"JProcess::fork() failed");
175 close(pipe_stdin [1]);
176 if (dup2 (pipe_stdin [0], STDIN_FILENO) == -1) { JSystemException(
"dup2-stdin"); }
178 close(pipe_stdout[0]);
179 if (dup2 (pipe_stdout[1], STDOUT_FILENO) == -1) { JSystemException(
"dup2-stdout"); }
181 close(pipe_stdout[0]);
182 if (dup2 (pipe_stdout[1], STDERR_FILENO) == -1) { JSystemException(
"dup2-stderr"); }
184 execl(path, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, (
char*) NULL);
186 throw JSystemException(path);
193 out = pipe_stdout[0];
194 err = pipe_stderr[0];
196 close(pipe_stdin [0]);
197 close(pipe_stdout[1]);
198 close(pipe_stderr[1]);
◆ out
int JSYSTEM::JProcess::out |
|
protected |
◆ err
int JSYSTEM::JProcess::err |
|
protected |
◆ in
int JSYSTEM::JProcess::in |
|
protected |
◆ gOut
◆ gErr
◆ gIn
The documentation for this class was generated from the following file:
void execute(const char *path, const char *arg0, const char *arg1=(char *) NULL, const char *arg2=(char *) NULL, const char *arg3=(char *) NULL, const char *arg4=(char *) NULL, const char *arg5=(char *) NULL, const char *arg6=(char *) NULL, const char *arg7=(char *) NULL, const char *arg8=(char *) NULL, const char *arg9=(char *) NULL)
Execute command.