Skip to content
Dashboard

Execute command (synchronous)

client.computers.exec.sync(stringid, ExecSyncParams { command, cwd, env, timeout_seconds } body, RequestOptionsoptions?): ExecSyncResponse { exit_code, stderr, stdout }
POST/computers/{id}/exec/sync

Execute a shell command and wait for completion, returning buffered stdout/stderr.

ParametersExpand Collapse
id: string
body: ExecSyncParams { command, cwd, env, timeout_seconds }
command?: string
cwd?: string
env?: Record<string, string>
timeout_seconds?: number
ReturnsExpand Collapse
ExecSyncResponse { exit_code, stderr, stdout }
exit_code?: number
stderr?: string
stdout?: string

Execute command (synchronous)

import Lightcone from '@tzafon/lightcone';

const client = new Lightcone({
  apiKey: process.env['TZAFON_API_KEY'], // This is the default and can be omitted
});

const response = await client.computers.exec.sync('id');

console.log(response.exit_code);
{
  "exit_code": 0,
  "stderr": "stderr",
  "stdout": "stdout"
}
Returns Examples
{
  "exit_code": 0,
  "stderr": "stderr",
  "stdout": "stdout"
}