Bash script per delay su orario

di Anonimizzato22012 il
1 risposte
Salve a tutti
con diversi esempi trovati online, ho modificato uno script per poter apportare un delay di un tempo determinato in una variabile, rispetto all'orario del tramonto. Purtroppo non riesco in nessun modo a riuscire a fargli fare quello che vorrei.
Esempio: vorrei che all'orario del tramonto venisse aggiunto 1 ora o 2, o 30 min, ma non ci riesco

Di seguito il codice

Grazie a tutti per l'aiuto

#!/bin/bash

#
# We retrieve sunrise and sunset times from www.datameteo.com
#
# 1) go to address http://www.datameteo.com/meteo/
# 2) insert your location inside field "Search a place"
# 3) copy and paste the internet address here in this script
#

url="http://www.datameteo.com/meteo/weather_Milan"

# we get all the web page
allfile=$( wget -qO-  $url | sed 's/<br/\n/g' | sed 's/<\/span>/\n/g' | grep -i ">Sunrise");

# we get the original sunrise/sunset time values
sunrise_str=$(echo $allfile | cut -d ":" -f 2,3 | sed 's|[^0-9]*\([0-9\:]*\)|\1 |g')
sunset_str=$(echo $allfile | cut -d ":" -f 4,5 | sed 's|[^0-9]*\([0-9\:]*\)|\1 |g')

#echo $sunset_str
#echo $sunrise_str


# we convert time values to Time in 24-hour format
sunset=$(date --date="$sunset_str" +%R)
sunrise=$(date --date="$sunrise_str" +%R)
echo $sunrise
echo $sunset

sunset=$(date --date="$sunset" +'%H:%M')
echo $sunset

delay=$(date --date 1:00 +'%H:%M')
echo $delay

#new_sunset=$(date -d "$sunset + $delay" +'%H:%M')
new_sunset=$(date -d "$sunset + 2 hour" +'%H:%M')

echo "$new_sunset"



1 Risposte

  • Nessuno riesce a darmi una mano in merito?
Devi accedere o registrarti per scrivere nel forum
1 risposte