ответвлён от encrypt/toot
45 строки
969 Б
Bash
Исполняемый файл
45 строки
969 Б
Bash
Исполняемый файл
#!/bin/bash
|
|
|
|
#
|
|
# CONFIGURATION
|
|
#
|
|
|
|
# Interval between two consecutive posts
|
|
FLOOR_HOUR_SLEEP_INTERVAL=5
|
|
CEILING_HOUR_SLEEP_INTERVAL=19
|
|
|
|
# File containing the toots to post
|
|
if [ ! -z "$1" ]; then
|
|
DATA_FILE=$1
|
|
else
|
|
DATA_FILE=megafono.txt
|
|
fi
|
|
|
|
# CONFIGURATION END
|
|
#
|
|
|
|
random_time_on_range(){
|
|
FLOOR=$1
|
|
CEILING=$2
|
|
RANGE=$(($CEILING-$FLOOR+1));
|
|
#echo "You will generate a random number between $FLOOR and $CEILING (both inclusive). There are $RANGE possible numbers!"
|
|
RESULT=$RANDOM;
|
|
#echo "We just generated the random number $RESULT, which might not be in the range we want";
|
|
let "RESULT %= $RANGE";
|
|
RESULT=$(($RESULT+$FLOOR));
|
|
echo $RESULT;
|
|
}
|
|
|
|
|
|
while :
|
|
do
|
|
# Last line should be empty, so we dont need an additional read here
|
|
# after the while loop
|
|
while read line
|
|
do
|
|
eval ./toot.sh $line
|
|
SLEEP_TOOT=$(random_time_on_range $FLOOR_HOUR_SLEEP_INTERVAL $CEILING_HOUR_SLEEP_INTERVAL)
|
|
sleep $SLEEP_TOOT"h"
|
|
done < ${DATA_FILE}
|
|
|
|
done
|