-
Notifications
You must be signed in to change notification settings - Fork 2
Basic Usage
The shhttp daemon creates an HTTP service that by default listens on path /v1/
for HTTP requests with JSON content. If the daemon is run with the defaults, the service will listen on http://localhost:2112/v1
.
You can submit a single command/script on the /v1/exec
path by doing a POST
on it with the following body:
POST http://localhost:2112/v1/exec
{
"Command": "echo",
"Args": ["shhttp is awesome"]
}
The command/script will be performed and the result will be returned as follows:
{
"Executable": {
"Command": "echo",
"Args": [
"shhttp is awesome"
],
"ExecPath": "",
"Stdin": "",
"Shell": false
},
"Stdout": "shhttp is awesome\n",
"Stderr": "",
"ExitCode": 0,
"Start": 1549611855,
"End": 1549611855
}
The command is executed as an exec
call which is why shell based expansion is not performed, for example, the following will will not perform as expected:
POST http://localhost:2112/v1/exec
{
"Command": "echo",
"Args": ["shhttp is awesome", "|", "grep", "awesome"]
}
will return
{
"Executable": {
"Command": "echo",
"Args": [
"shhttp is awesome",
"|",
"grep",
"awesome"
],
"ExecPath": "",
"Stdin": "",
"Shell": false
},
"Stdout": "shhttp is awesome | grep awesome\n",
"Stderr": "",
"ExitCode": 0,
"Start": 1549612162,
"End": 1549612162
}
To make the shell work, you need to set the Shell
property in the request:
POST http://localhost:2112/v1/exec
{
"Command": "echo",
"Args": ["shhttp is awesome", "|", "grep", "awesome"],
"Shell": true
}
resulting in:
{
"Executable": {
"Command": "echo",
"Args": [
"shhttp is awesome",
"|",
"grep",
"awesome"
],
"ExecPath": "",
"Stdin": "",
"Shell": true
},
"Stdout": "shhttp is awesome\n",
"Stderr": "",
"ExitCode": 0,
"Start": 1549612268,
"End": 1549612268
}
For this, the default shell sh
is used.
The full body of the request is as follows:
{
"Command": "(string) The command to execute",
"Args": "(string []) Array of arguments to pass to the above command",
"BaseDir": "(string) The directory from which the command should be invoked",
"Stdin": "(string) This string will be piped into the stdin of the command",
"Shell": "(bool) Whether to execute this command on shell",
"Env": "(json) String key-value pairs that are injected as environment variables"
}
Basic Usage -> Jobs -> Saved Jobs -> Job Queue