Lugaru's Epsilon Programmer's Editor
Context:

|
|
Previous
|
Up
|
Next
| |
Calling Windows DLLs |
Primitives and EEL Subroutines |
Concurrent Process Primitives |
Epsilon User's Manual and Reference >
Primitives and EEL Subroutines >
Operating System Primitives >
Running a Process
int shell(char *program, char *cline, char *buf, ?int flags)
The shell( ) primitive takes the name of an executable file (a
program) and a command line, pushes to the program, and gives it that
command line. The primitive returns the result code of the wait()
system call, or -1 if an error occurred. In the latter case, the
error number is in errno.
The first argument to shell( ) is the name of the actual file a
program is in, including any directory prefix. The second argument to
shell( ) is the command line to pass to the program.
If the first argument to shell( ) is an empty string "",
Epsilon behaves differently. In this case, Epsilon runs the
appropriate shell command processor. (Note that "" is not the
same as NULL, a pointer whose value is 0.) If the second argument is
also "", Epsilon runs the shell interactively, so that it
prompts for commands. Otherwise, Epsilon makes the shell run only
the command line specified in the second argument. Epsilon knows
what flags to provide to the various standard shells to make them run
interactively, or execute a single command and return, but you can
set these if necessary. You can also set the command processor
Epsilon should use. See Running Other Programs.
Under Windows, when you provide a nonempty first argument, Epsilon
won't search the path for the specified file. To run a file on the
path, put its name as the second argument and leave the first as
"". This technique is also necessary to execute batch files, use
internal commands like "dir", or do command-line redirection.
The third argument to shell( ) controls whether the output of the
program is to be captured. If "", no capturing takes place.
Otherwise the output is inserted in the specified buffer, replacing
its previous contents.
In the Windows GUI version, and when Epsilon for Unix runs as an X11
program, Epsilon starts the program and then immediately continues
without waiting for it to finish, whenever the first three arguments
to shell( ) are "". Otherwise, Epsilon waits for the program
to finish. The SHELL_SYNCH flag forces Epsilon to wait; the
SHELL_NO_SYNCH flag tells Epsilon not to wait for the
program.
The remaining flags for shell( ) only apply to the Windows
version. SHELL_HIDE makes the resulting program's main
window hidden; SHELL_MINIMIZED minimizes it, and
SHELL_MAXIMIZED maximizes it. Normally Epsilon inserts an
EPSRUNS=Y setting into the environment passed to the child
process, in case some program wants to know if Epsilon invoked it.
The SHELL_KEEP_ENV flag prevents that.
int do_push(char *cmdline, int cap, int show)
The do_push( ) subroutine is a convenient way to call
shell( ). It uses the command processor to execute a command
line (so the command line may contain redirection characters and the
like). If cap is nonzero, the subroutine will capture the output
of the command to the process buffer. If show is nonzero, the
subroutine will arrange to show the output to the user. How it does
this depends on cap. To show captured output, Epsilon displays
the process buffer after the program finishes. To show non-captured
output, Epsilon (non-GUI versions only) waits for the user to
press a key after the program finishes, before restoring Epsilon's
screen. If show is -1, Epsilon skips this step.
This subroutine interprets the variable
start-process-in-buffer-directory and takes care of displaying
an error to the user if the process couldn't be run.
|
Previous
|
Up
|
Next
| |
Calling Windows DLLs |
Primitives and EEL Subroutines |
Concurrent Process Primitives |

Copyright (C) 1984, 2012 Lugaru Software Ltd. All Rights Reserved.
|