Calling Deno from a shell script is actually very straightforward. First, ensure Deno is installed on your system. The installation process can be found in detail on the official Deno website Deno Official Website.
Installing Deno
For Linux or macOS systems, you can use the following simple command:
bashcurl -fsSL https://deno.land/x/install/install.sh | sh
For Windows, use PowerShell:
powershelliwr https://deno.land/x/install/install.ps1 -useb | iex
Calling Deno from a Shell Script
Assuming Deno is already installed, you can call it from a shell script to run a Deno program. First, create a simple Deno script. For example, create a new file hello.ts with the following content:
typescriptconsole.log("Hello from Deno!");
Next, create a shell script to run this Deno script. Create a file named run_deno.sh with the following content:
bash#!/bin/bash # Run the Deno program deno run hello.ts
Ensure your shell script has executable permissions. You can grant execution permissions with the following command:
bashchmod +x run_deno.sh
Finally, you can run this script in the terminal to execute your Deno program:
bash./run_deno.sh
This will output:
shellHello from Deno!
Summary
The process of calling Deno from a shell script includes:
- Ensure Deno is installed on your system.
- Write the Deno program.
- Create a shell script to call the
deno runcommand to execute the Deno program. - Set executable permissions for the shell script.
- Run the script.
This approach is ideal for automation scripts and tasks, allowing Deno-developed programs to integrate seamlessly into larger system environments.