sandbox.run() to execute a command and collect its output. After
installing LithosBox, run this example with lithosbox python:
stdout, stderr, and exit_code. A nonzero exit code does
not raise an exception unless you call .check().
The examples below continue with the same sandbox.
Choose a command format
Pass a string when you want shell features such as pipes and redirects:stdin to send input to a command:
Keep shell state
A regularrun() starts a new shell. Files persist, but changes to the working
directory or environment variables do not carry into the next call.
Use a session for commands that share shell state:
Start a background job
Usebackground=True for a server, worker, or command that may take longer than
about 110 seconds. It accepts a shell string and returns after the job starts.
Redirect output to a file so you can read it later.
background=True does not accept stdin or return a process ID. Write input to a
file first. If you need to stop the job individually, have it record its process
ID and use that ID in a later command.
Command limits
Synchronousrun() and session calls allow about 110 seconds. Each argument can
contain at most 131,071 bytes, and stdin can contain up to 4 MiB per call.
Each output stream is limited to 16 MiB. Check result.truncated before relying
on a large result; use files for binary output or larger results. See
Work with files for transfer options.
When you have collected your results and no longer need the sandbox: