Run Shell Script From Your Website

Here’s how to run a shell script from your website. You’ll need 2 files.

Here’s the contents of foo.php. Wrap your output with ‘pre’ for better formatting.

<?php
$output = shell_exec('/var/www/html/bar.sh 2>&1');
echo "$output";

Here’s the content of bar.sh. Output will be displayed on web page.

#!/bin/bash
now="$(date +'%y%m%d')"
echo $now
aws s3 ls

Icecast on Docker

Run Icecast2 on a Docker container.

docker run -d \
-p 8000:8000 \
-e ICECAST_SOURCE_PASSWORD=aaaa \
-e ICECAST_ADMIN_PASSWORD=bbbb \
-e ICECAST_PASSWORD=cccc \
-e ICECAST_RELAY_PASSWORD=dddd \
moul/icecast

Access localhost:8000 on browser. Github.

Run Bash Script in GitBash

Unfortunately, you can’t run Bash scripts in GitBash the normal way. Here’s the workaround. You have to use sh script.sh

# Normal use
./script.sh
# Running it in GitBash
sh script.sh