Sage-Code Laboratory

Eve Commands

Eve enable direct interaction with system commands and shell scripts. This make Eve a true scripting language. You can call a script using: "shell" command with parameters and pipeline operators.

System variables

System variables start with prefix $. You can export Eve shared variables to the operating system using "export" command. When you work with files and folders, the system security is effective. You can't access the folders or the files over which you have no user rigts.

These are several system variables available by default in Eve. These are changing automaticly sometimes as an effect of the commands.

Shell command

We introduce: "shell" keyword. This will send a command to the operating system and will execute a native kernel command. This new keyword is also a EVE CLI command.

Shell syntax

shell [input +>] command [+> output] 

command ::= "os_command -flags #s #s ..." ? (value, value ...)
os_command::= {ls, cd, rm, chmod, ...}

Note: The shell commands are string literals or variables. Binding Eve variables to OS command is using string interpolation. That means you can use #s or #(var_name) in the command string with ? operator.

Using shell

Shell command is useful to run a shell script (.sh) or a os command, usually this will produce an output to console. The output can be redirected to a file or piped to another command.

capture output

You can capture the output as a list of strings using operator +>. In next example we capture a list of files

# listing files in folder "test"
driver shell_output:
  set files: ()String;
  shell "cd #($HOME)/test";
  shell "ls -l *.dat" +> files;
    new file: String:
  for file in files loop
    print file;

accept input

# execute a shell script
driver shell_input:
  set files: ()String;
  shell "cd #($HOME)/test";
  shell ("hello", "world") +> "./";

The input must be accepted by the script using "read".

while read line
  echo $line
done < /dev/stdin

Using classes

Eve is using classes that simulate the operating system functionality. These classes are not yet designed. These system classes are loaded automaticly, you do not have to import anything when you use them.


Next example demostrate how to use class Files to read a directory for files. Notice we do not use shell command to do it, we simple create a list of files.

# listing files in folder "test"
driver folder_test:
  set files: ()File;
  set folder: Folder;
  let folder := Folder($HOME/"test") 
    new file: File:
  for file in folder.files() loop

Read next: Databases