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 line cmd 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 “prog tfn cmdline” where tfn is a temporary filename rxcXXXXX.tmp where XXXXX is a random number. If cmd is empty tfn is empty, otherwise, it writes cmd to rxcXXXXX.tmp. The prog 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, then prog is taken literally as the name of a program. The run command collects stdout and returns these lines.

run: String -> List String

run(cmdline) returns run(cmdline,"","").

setExecutable!: (String, String) -> String

setExecutable(prog, cmd) stores the commandline cmd under the key/name prog. It is not checked whether cmd is reachable via the current PATH, so it is advisable to set the full path to the executable together with its standard options.