run Command

The run command is used to execute a script file within the HotRIO firmware environment. The script file can be provided as a path parameter, and the command reads and executes the script line by line, as if they were input manually into the shell.

Usage

The run command has the following syntax:

run <path_to_script>

Where: - <path_to_script> (required): The relative or absolute path to the script file to be executed. The script file should contain a series of shell commands.

Command Description

  • With the path to the script: The run command reads the file specified by the given path and executes it line by line, as if the commands were typed into the shell manually.

Examples

  1. Execute a script located at /home/user/script.txt:
    run /home/user/script.txt
    Running script: /home/user/script.txt
    Command executed: <output of the script>
    
  2. Attempting to execute a script without specifying a file path will result in an error:
    run
    Error parsing run command, this command only supports a path to the file to run as parameter.
    

Error Handling

If the run command encounters an issue with the script or the provided path, the following error messages may be displayed: - “Error parsing run command, this command only supports a path to the file to run as parameter.” - “Could not parse file path provided” - “Error opening script file path.”

The command will stop executing if any error occurs while processing the script, and no further commands will be executed.

Command Execution

When the run command is executed, the following steps occur: 1. The path to the script is parsed and validated. 2. If valid, the script file is opened and read character by character. 3. Each character is processed as input to the shell, mimicking user input. 4. If a command fails during execution, the script execution will stop unless the -f flag is used to force execution (not implemented in the provided code, but can be added for future functionality). 5. After the script is executed, the shell state is restored to its previous condition, including the working directory and shell path.

If any of the commands in the script file fail, the run command will halt further execution by default. This behavior ensures that script execution is consistent with the commands in the script.