Skip to main content
Module

x/run_simple/example.ts

Simple run function to execute shell commands in Deno.
Latest
File
import { run } from "./mod.ts";
// Simple commandconst dir: string = await run("ls -l");console.log(dir);
// Command with variable argumentconst uid = 1000;const idLine: string = await run(["id", uid]);console.log(idLine);
// An argument contains spacesconst remoteHost = "10.20.30.40";const remoteCommand = "ps -ef --forest";const remoteProcessTree: string = await run(["ssh", remoteHost, remoteCommand]);console.log(remoteProcessTree);
// Supply STDIN to the commandconst contents = `# Remote file
This will be the contents of the remote file.`;await run( ["ssh", remoteHost, "bash", "-c", "cat > remote_file.md"], { stdin: contents },);