Report Command Terminal

 ๐Ÿ”ง STEP 1: Navigate to your folder

Open your SSH terminal and run:


bash

Copy

Edit

cd ~/url-checker

๐Ÿ”ง STEP 2: Clean up previous files (optional)

To start fresh, delete the old report:


bash

Copy

Edit

rm -f report.txt

๐Ÿ”ง STEP 3: Create or update your script

Open or create the script file:


bash

Copy

Edit

nano cache-check.sh

Paste this inside:


bash

Copy

Edit

#!/bin/bash


rm -f report.txt  # Clear old report


while read -r url; do

    echo "Checking: $url"


    # Get headers silently

    headers=$(curl -s -I "$url")


    # Extract HTTP status code

    status_code=$(echo "$headers" | grep HTTP | awk '{print $2}' | head -n 1)


    # Extract Cloudflare cache status

    cf_status=$(echo "$headers" | grep -i "cf-cache-status" | awk '{print $2}')


    # Extract LiteSpeed cache control

    ls_status=$(echo "$headers" | grep -i "x-litespeed-cache-control" | cut -d' ' -f2-)


    # Output to file

    {

        echo "URL: $url"

        echo "  HTTP Status: ${status_code:-Unknown}"

        echo "  Cloudflare: ${cf_status:-MISS/Not Cached}"

        echo "  LiteSpeed: ${ls_status:-MISS/Not Cached}"

        echo "----------------------------------------"

    } >> report.txt


    # Echo to terminal

    echo "HTTP Status: ${status_code:-Unknown}"

    echo "Cloudflare: ${cf_status:-MISS/Not Cached}"

    echo "LiteSpeed: ${ls_status:-MISS/Not Cached}"

    echo "----------------------------------------"


    sleep 1

done < urls.txt

Save and exit:


Press Ctrl + O, then Enter to save


Press Ctrl + X to exit


๐Ÿ”ง STEP 4: Make the script executable (only once)

bash

Copy

Edit

chmod +x cache-check.sh

✅ STEP 5: Run the checker

Now run it:


bash

Copy

Edit

./cache-check.sh

This will:


Read each URL from urls.txt


Check status, Cloudflare cache, and LiteSpeed cache


Output results to both terminal and report.txt


๐Ÿงพ STEP 6: View your report

When it’s done:


bash

Copy

Edit

cat report.txt

Comments

Popular posts from this blog

Bursary Prompt

Cache Report

Report 25 August