Sage-Code Laboratory
index<--

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: "call" 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: "call" 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

call [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 call

Call is useful to execute an OS shell script (.sh) or a OS commands, 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;
process:
  call "cd #($HOME)/test";
  call "ls -l *.dat" +> files;
  cycle: 
    new file: String:
  for file in files loop
    print file;
  repeat;
return;

accept input


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

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

#!/bin/bash 
while read line
do
  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.

Example:

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;
process:
  let folder := Folder($HOME/"test"); 
  cycle: 
    new file: File:
  for file in folder.files() loop
    print file.name;
  repeat;
return;

Read next: Databases