Post by Shahana MS
Certified AWS AI Practitioner 🏅| AI-DS | Cloud Computing|Machine Learning | Pre-final Year Student|AWS×2| | B.Tech Student at SJCE| AWS X 4 badges
Day2 at #devOpschallenge
This challenge comprises of the following:
✒️ Displaying messages and date :
#!/bin/bash
echo "Hello DevOps! Today's date and time is: $(date)"
✒️ Checking website status :
#!/bin/bash
# Define the website to check
WEBSITE="https://www.learnxops.com"
DOMAIN="learnxops.com"
# Check website availability using curl
if curl -Is "$WEBSITE" --max-time 5 | head -n 1 | grep -q "200\|301\|302"; then
echo "✅ Success: $WEBSITE is reachable via curl!"
else
echo "⚠ Curl check failed, trying ping..."
# Check website availability using ping
if ping -c 2 -W 2 "$DOMAIN" > /dev/null 2>&1; then
echo "✅ Success: $DOMAIN is reachable via ping!"
else
echo "❌ Failure: $WEBSITE is not reachable via curl or ping."
fi
fi
✒️ Validating file existence :
#/bin/bash
# Check if a filename argument is provided
if [ $# -eq 0 ]; then
echo "❌ Error: No filename provided."
echo "Usage: ./check_file.sh