I have .sh script in UbuntuServer (VM):
response=$(curl -H 'Accept: application/vnd.twitchtv.v5+json' -H 'Authorization: OAuth 9f65dd6onr07vhpdqblbiix5rl0tch' -X GET 'https://api.twitch.tv/kraken/streams/127060528' | jq -r '.stream');
now=$(date +"%Y-%m-%d %T");
echo "$now" >> log.txt;
echo "$response" >> log.txt;
if [[ "$response" == "null" ]]
then
echo "ZERO"
else
streamlink -o "dump/stream_$now.mp3" twitch.tv/mahetirecords/clip/FreezingEncouragingCougarSuperVinlin audio
echo "STREAM"
fi
When I run the script through the bash, the THEN-way is triggered. When I run the script through crontab, the ELSE-way is triggered. WHY?
Crontab -e:
* * * * * /home/chesterlife/twitch-interceptor/script.sh
If the stream is offline, then "$response" return null. This is text-null because var=""; if [ "$var" == "$response" ]; then echo "true"; else echo "false"; fi
return false
Any ideas?