Command Line Interface
The REX executor (rex.php) offers a Command-Line Interface (CLI) to fetch and execute remote code.
$ php rex.php http://rex.purplepixie.org/examples/hello-world/
The above instructs REX to fetch the code from rex.purplepixie.org/examples/hello-world/index.rex and execute it displaying any output to the screen.
In addition to the file (or files) specified there are a number of switches and options you can provide.
These control the settings detailed in the
section of the documentation.
CLI Switches and Options
REX Stack and Environment Variables
Display command help and exit
- --quiet=1 (or --quiet=0)
Turn on (1) or off (0) the quiet mode (parsing errors are output or not)
- --mute=1 (or --mute=0)
Turn on (1) or off (0) muting of the executor errors (similar to quiet but quiet is for the framework not the executor)
Set the block size (fetching blocks) to this size in bytes
Set the base directory to X. The base is normally set as the first directory used so any unqualified files then requested are loaded from that directory. This overrides that and sets the base, allowing you to specify just filenames to execute (the X can be enclosed in quotes if required for spaces in the path name)
Sets the default file to look for if just a directory is called (the default is index.rex)
- --continue=1 (or --continue=0)
Continues requesting and executing the files listed even if an error has occured (default is off so execution stops)
- --debug=1 (or --debug=0)
Turns on the debug mode including outputting all the states before execution and showing each file starting and finishing execution.
The CLI can be used to specify REX stack variables and REX environment variables on startup.
- --set variable=value
Sets a stack variable of name 'variable' to 'value'
- --env variable=value
Sets an environment variable of name 'variable' to 'value'
Note that both the variable names and values can be quoted strings if required to include data with spaces.
Anything passed and not prefixed with -- will be treated as a filename to be loaded into the list for execution. These are done in order.
Please note however that the options are set once at runtime and not parsed in order with the filenames so, for example, if you call a filename then set the base and then call another filename both will have the base set when executed.
$ php rex.php --debug=1 http://codeserver/rex/
Will execute the file http://codeserver/rex/index.rex with debug output
$ php rex.php --base="http://codeserver/my files/" code1.rex code2.rex
Will execute first code1.rex then code2.rex from the directory "http://codeserver/my files/"
$ php rex.php --set somevar="something or other" --default=rexcode.php http://codeserver/rex/
Will set the variable somevar to be "something or other" in the variable stack and then execute http://codeserver/rex/rexcode.php