Exec one-off commands

Learn how to create and manage compute instances for executing code securely.

Exec one-off commands

Execute any shell command within the secure environment:

// Run a simple command
const result = await compute.exec('echo "Hello World"');
console.log(result); // Output: Hello World

// Run multiple commands
const result = await compute.exec('pwd && ls -la');

// Run a Python script
const result = await compute.exec('python3 script.py');

// Install packages
const result = await compute.exec('npm install express');

The exec method runs commands in a shell environment, allowing you to:

  • Execute any shell command
  • Run scripts in any language
  • Install packages
  • Chain commands using && or ||
  • Use pipes and redirections