Skip to main content

Running shell scripts

Running shell scripts is similar to running binaries, but scripts are executed in a shell. We can run a script with yeet like this:

yeet run <service> <script>

We can also use scp to upload and run a script in one step. This is equivalent to using yeet run.

scp <script> <service>:

Shell scripts are detected by the presence of a shebang (#!) at the top of the file. As long as the first line of the file is a valid shebang, it will be executed with the system's default shell. Be sure any dependencies are installed on the system you're running on.

Example

Deploying a Python webserver

Below is server.py, a simple Python script that listens on port 8080. Let's run it on our Catch server.

#!/usr/bin/env python3

from http.server import SimpleHTTPRequestHandler, HTTPServer

# Define the server address and port
server_address = ('', 8000)

# Create the HTTP server
httpd = HTTPServer(server_address, SimpleHTTPRequestHandler)

# Start the server
print("Starting server on port 8000...")
httpd.serve_forever()

The nice thing about scripts is there's no building required. The next step is to just run the script on our server. Let's run the script on our server as a service called hello-server.

yeet run hello-server ./server.py

We can check that the service is running with yeet status.

$ yeet status hello-server
SERVICE TYPE CONTAINER STATUS
hello-server service - running

Our server is running on port 8080. Let's curl our server to see that it's running.

$ curl http://<ip-of-server>:8080
Hello, World!
tip

Catch includes a built-in TCP proxy, enabling you to access your services over the Tailnet. This means you can simply curl http://catch:8080 to reach your service.