Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: DrStevenStrange Newsgroups: comp.sys.raspberry-pi Subject: AI Written Bash Script Date: Thu, 12 Dec 2024 12:43:14 +0000 Organization: A noiseless patient Spider Lines: 34 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 12 Dec 2024 13:43:16 +0100 (CET) Injection-Info: dont-email.me; posting-host="e8ebc7fc6dd16a85227e2111ae3f6a89"; logging-data="2255015"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18x1AN/ilMl5nbskL7jOnU8DD8xCj+QSaZCdDly1sC+QQ==" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 15.2; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19 Cancel-Lock: sha1:U7yesdcWHc9Jcafyre/tNwDVV2U= X-Mozilla-News-Host: news://news.eternal-september.org:119 Bytes: 2233 Ok - don't laugh My coding skills are pitiful so I asked my resident Ai to write a bash script to call a webcam script (I did write this one) only between sunrise and sunset. it produced this and it works! My question is - how can I amend the script so it starts 30 minutes BEFORE sunrise and stops 30 Minutes after? #!/bin/bash # Set your latitude and longitude LATITUDE="mine" LONGITUDE="mine" # Fetch sunrise and sunset times in UTC SUN_TIMES=$(curl -s "https://api.sunrise-sunset.org/json?lat=$LATITUDE&lng=$LONGITUDE&formatted=0") SUNRISE=$(echo $SUN_TIMES | jq -r '.results.sunrise') SUNSET=$(echo $SUN_TIMES | jq -r '.results.sunset') # Convert sunrise and sunset times to seconds since epoch SUNRISE_EPOCH=$(date -d "$SUNRISE" +%s) SUNSET_EPOCH=$(date -d "$SUNSET" +%s) CURRENT_EPOCH=$(date +%s) # Check if the current time is between sunrise and sunset if [ $CURRENT_EPOCH -ge $SUNRISE_EPOCH ] && [ $CURRENT_EPOCH -le $SUNSET_EPOCH ]; then echo "It's between sunrise and sunset. Running the other script..." # Call the other script ./webcam.sh # Replace with the path to your script else echo "It's not between sunrise and sunset." fi