Add eval support on url list

This commit is contained in:
adrien 2019-04-16 19:48:11 +02:00
parent 9ce8dc62b5
commit f9b9f827ff
2 changed files with 18 additions and 2 deletions

View File

@ -1,2 +1,4 @@
#%COMMANDE
%echo -e \"ma commande et les erreur:\\n~outS~\"
#HTTP_status_codes:URL[:PORT]
301:https://google.com:443
200:https://iglou.eu

View File

@ -1,10 +1,11 @@
#!/bin/sh
#!/bin/bash
trap "exit 0" 2 3
time=60
cerebro () {
while read line ; do
[ "${line:0:1}" == "#" ] && continue
[ "${line:0:1}" == "%" ] && cmdR+=("${line:1}") && continue
url=${line#*:}
status=${line%%:*}
@ -16,6 +17,7 @@ cerebro () {
if [ -z "$outS" ]; then
out="OK!\n$(date +"%d/%m/%Y %T")"
else
xPsy
out="$outS"
fi
@ -23,10 +25,22 @@ cerebro () {
echo -e "$out" > "$html"
}
xPsy () {
local _buff=""
for ((i = 0; i < ${#cmdR[@]}; i++))
do
_buff="${cmdR[$1]}"
_buff="${_buff/~outS~/$outS}"
eval "$_buff"
done
}
root="$(cd "$(dirname "$0")"; pwd)"
html="${1:-${root}/status.html}"
urls="${2:-${root}/url.list}"
outS=""
cmdR=()
if [ "$1" == "-h" ]; then
echo -e "usage : $(basename "$0") [<html output path> [<url list path>]]\n"