Run a command object, constructed with backticks, and tell whether it was successful (exited with a code of 0). An exception is raised if the process cannot be started.


julia> success(`ls`)

julia> success(`rm non_existing_file.txt`)
  1. Check if a command was successful:

    julia> success(`ls`)

    This example runs the ls command and checks if it was successful. If the command exits with a code of 0, success returns true.

  2. Handle unsuccessful commands:
    julia> success(`rm non_existing_file.txt`)

    It checks if a command to remove a non-existing file was successful. Since the file doesn't exist, the command will fail and success returns false.

Common mistake example:

julia> success(`invalid_command`)
ERROR: could not spawn `invalid_command`: no such file or directory (ENOENT)

In this example, an invalid command is provided, which leads to an error. Make sure to provide a valid command that can be executed to avoid such errors.

See Also

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field

Checking you are not a robot: