30 lines · 798 B · TypeScript
RawDownload
// Run shell commands inside the VM. import { AgentOs } from "@rivet-dev/agentos-core"; const vm = await AgentOs.create(); // Simple commandsconst echo = await vm.exec("echo 'Hello from the shell!'");console.log(echo.stdout); // Pipesconst piped = await vm.exec("echo 'hello world' | tr a-z A-Z");console.log("Piped:", piped.stdout.trim()); // File manipulationawait vm.exec("echo 'line 1' > /tmp/test.txt");await vm.exec("echo 'line 2' >> /tmp/test.txt");await vm.exec("echo 'line 3' >> /tmp/test.txt"); const cat = await vm.exec("cat /tmp/test.txt");console.log("File contents:");console.log(cat.stdout); // grepconst grep = await vm.exec("grep '2' /tmp/test.txt");console.log("Grep result:", grep.stdout.trim()); console.log("Exit code:", grep.exitCode); await vm.dispose();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t