Manual:DIL Manual/shell()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:20, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

shell()

Function (integer). Starts a program from the server's allow directory.

shell(cmd : string)

Runs ./allow/ followed by cmd through the system shell, in a thread of its own, from the directory the server runs in (vme/bin, so vme/bin/allow/). The game doesn't wait for it. The first word of cmd is the program; the rest are its arguments. wiz.zon uses it to start the build and deploy scripts.

Parameters

Name Type Meaning
cmd string The program in vme/bin/allow/ and its arguments, as for a shell: "compile.sh", "test.sh olle golle".

Returns

Integer: 0 when the thread was started, otherwise the error code of starting it. It says nothing about the program itself: whether it ran and how it ended is written to the log only ("success system(...)" or "fail system(...)"). It fails when cmd is a failed value; a string variable that was never set is a type error, and the program stops.

Notes

  • Only zones with access level 0 (the fourth column of vme/etc/zonelist) may use
 it. Elsewhere it writes "attempt run shell() w/o access" to the zone's log and the program
 stops.
  • A program name with /, ; or .. is refused (in the log).
 Only that first word is checked: the arguments reach the shell as they are, so never put
 text a player typed in them.
  • Pass a constant string. A string built in the call ("x.sh " + name) is freed
 while the new thread may still be reading it.

Example

dilbegin start_build(pc : unitptr);
var
   i : integer;
code
{
   if (pc.level < 254)
      quit;
   i := shell("compile.sh");
   act("The build starts. (" + itoa(i) + ")", A_ALWAYS, pc, null, null, TO_CHAR);
   quit;
}
dilend

Lets a high god start the build script vme/bin/allow/compile.sh, as the compiler room in wiz.zon does.

See also