Run shell commands
This guide runs an arbitrary shell command through the proxy, using the Command execution mode. Prefer running scripts when the set of operations is known in advance; see Execution modes for the trade-off.
Prerequisites
- The proxy is installed and running inside your network.
- A Proxy account with execution mode Command, connected to an exec-mode profile on the proxy.
Get started walks through the equivalent setup for script mode; for shell commands, configure
the profile with
mode = "exec"instead (see Configuration).
Configure the shell
The global shell setting determines which shell executes the commands (powershell, unix, or cmd), together
with the environment variables the command receives; the profile sets the working directory:
shell = "powershell"
[[profile]]
name = "windows-commands"
mode = "exec"
token = "<your-token>"
key = "<your-secret-key>"
automator_url = "<the Automator URL copied from the account>"
All options are described in the configuration reference.
Send a command from a package
A package sends the complete command line to execute:
const result = executeOnProxy("windows-commands", {
command: "Get-Service -Name W32Time",
});
log(result.data.stdout);
Optionally, parameters can carry an extra string that is appended to the command line:
const result = executeOnProxy("windows-commands", {
command: "Get-Service",
parameters: "-Name W32Time",
});
The result contains the command's output in data.stdout and data.stderr; err is set when the execution failed.
See executeOnProxy for the full description.