Skip to content
Not available in DartThis function is not part of the Dart package. The documentation below is for JavaScript and Python.

runCommand

Requires a Node.js runtime ('qsu/node')

It returns the result that is output after entering and executing the command prompt command.

Never pass untrusted input

The command runs through the system shell, so anything the shell understands is executed. Building a command by concatenating user input allows arbitrary commands to run: runCommand('ls ' + userInput) with an input of .; rm -rf ~ runs both. Only call this with commands your own code decides.

There is no timeout, so a command that never returns leaves the call pending forever.

The output is also limited by the default maxBuffer (1 MB), and the call fails once it is exceeded.

Parameters

NameTypeRequiredDefault
commandstringstr
The command to run. It is executed through the shell.

Returns

Promise<string | null>

str | None

Examples

javascript
console.log(await runCommand('echo a')); // Returns 'a'
python
print(runCommand('echo a'))  # Returns 'a'

Released under the MIT License