Cows allows to execute external commands, scripts and programs with the cmd
and exec
functions. The former
is used to execute external commands, the latter to execute external scripts or programs.
This distinction can be confusing: after all most Unix commands are themselves scripts or
programs. So, let's say that cmd
is used to execute
commands like ls: when you type it in a shell you don't mind
whenever ls is a shell build in function or a program: from the
user's point of view it's simply a standard system command.
The exec
function instead, is used to execute scripts or
programs written by the site author; as an example you can create a shell script called
navigation.sh and execute it within a Cows script. External
shell scripts should be used everywhere the simple Cows language is too limiting for
you.
Now, you may be tempted to use everywhere external scripts and wonder why Cows exists at all. The reason is simple: external scripts can't be analyzed for dependencies, otherwise we should write a complete interpreter for each language. The idea is to use Cows for easy tasks introducing dependencies, and switch to another language (via external scripts) when Cows result too limiting and there are no dependencies to track. When Cows result too limiting but there are dependencies to track? The decision is up to you: probably the best compromise is to use an external script and track dependencies manually (Section 23.3).
Both cmd
and exec
inserts
output from command or script within Cows' generated file; two other functions, evalcmd
and evalexec
return the
output as a string variable.
cmd (command
);
Execute command
and redirect its standard output within
output file; command
can comprehend options (e.g. ls -l) and can be any valid expression:
cmd ("literal_command")
cmd (variable_storing_command_name)
cmd (variable_storing_command_name + variable_storing_options)
print ("Site created on "); cmd ("uname -a");
On my machine, Cows' output is:
Site created on FreeBSD veganstar.local 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Thu Nov 3 09:36:13 UTC 2005 root@x64.samsco.home:/usr/obj/usr/src/sys/GENERIC i386
This manual can be downloaded from http://www.g-cows.org/.