RunExternalCommand¶
runextcmd.spad line 73 [edit on github]
RunExternalCommand provides an interface to run an external command and capture its standard output. Examples: run("ls
.spad”, ``””``, ``””``) run(“ls”, ``””``, ``”*``.spad|sed ``’s/``\.spad//``’”``) run(“bash”, “grep ‘)abbrev package’ *.spad”, “|sed ``’s/``. //
'"
) run(“cat”, “divisors(6)”, “|fricas -nosman|grep '^
(1)'"
) run(“cat”, “factorial(20)”, "|
sage -q
| sed ‘s/^sage: //
'"
)
- execute: String -> Void
execute(cmd)
executes the command linecmd
without returning anything. That is, in fact, the same as: systemCommand(“system “cmd
)$MoreSystemCommands
- knownCommands: () -> List List String
knownCommands()
returns a list of all program names together with their respective commandline values.
- run: (String, String, String) -> List String
run(prog,cmd,cmdline)
executes “progtfn
cmdline” wheretfn
is a temporary filename rxcXXXXX.tmp
where XXXXX is a random number. Ifcmd
is emptytfn
is empty, otherwise, it writescmd
to rxcXXXXX.tmp
. Theprog
is assumed to read the temporary file and send its output to stdout. The temporary file(s
) are assumed to be created in the current directory and removed after execution.prog
is considered to be a key in previously stored executables hash table via setExecutable!. If the table has no such key, thenprog
is taken literally as the name of a program. The run command collects stdout and returns these lines.