Saturday, May 4, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 1013  / 1 Year ago, fri, december 2, 2022, 1:30:15

excuse my bad english:


This is the situation; I make my own IPTV lists taking the URLs of free sites and passing them to the smart tv, I would like to know which urls work and which ones don't to replace them, and doing it manually is an impossible task, I found the snap bash script to delete old snaps fantastic from the terminal with a single command, something like this would work for me, but OBVIOUSLY I don't know anything about scripts, bash or programming, if you could help me with a bash script that checks all the URLs of a .txt document in the terminal indicating which ones are up and which ones down I would appreciate very much, that would save me a lot of time, I appreciate your help in advance!


More From » command-line

 Answers
1

Ive tested it a couple of times, seems to work ok.



#!/bin/bash

if [ $# -eq 0 ]
then
fin=-
else
fin=$1
fi

urlarr=( $(cat $fin | strings | tr ',:/' '


' | grep -i ".com|.net|.edu|.org|^[0-9].*.[0-9].*.[0-9].*.[0-9].*" | tr '
' ' ' ) )

for i in ${urlarr[@]}
do
if ping -c1 -w1 $i 2>&1 >/dev/null
then
echo $i is up.
else
echo $i is down.
fi
done

exit $?

[#230] Friday, December 2, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cretanol

Total Points: 320
Total Questions: 99
Total Answers: 115

Location: Australia
Member since Sat, May 27, 2023
1 Year ago
cretanol questions
;