39 lines
1.0 KiB
Bash
Executable File
39 lines
1.0 KiB
Bash
Executable File
#!/bin/sh -e
|
|
|
|
# Retrieve a header from somewhere. Don't care where.
|
|
echo "GET HTTP/1.1" | ncat --ssl 205.166.94.16 443 | grep Date > /tmp/date.jnk
|
|
|
|
# Month lookup table. Horrible, but I don't know a better method...
|
|
# Please forgive me for this sin, Patriarch Bourne.
|
|
month=`cut -d ' ' -f 4 /tmp/date.jnk`
|
|
case "$month" in
|
|
Jan) month=01 ;;
|
|
Feb) month=02 ;;
|
|
Mar) month=03 ;;
|
|
Apr) month=04 ;;
|
|
May) month=05 ;;
|
|
Jun) month=06 ;;
|
|
Jul) month=07 ;;
|
|
Aug) month=08 ;;
|
|
Sep) month=09 ;;
|
|
Oct) month=10 ;;
|
|
Nov) month=11 ;;
|
|
Dec) month=12 ;;
|
|
esac
|
|
|
|
x=1
|
|
for each in day year time
|
|
do
|
|
export $each=`cat /tmp/date.jnk | tr ' ' '\n' | grep -E [0-9] | sed s/\://g | tr '\n' ' ' | cut -d ' ' -f $x`
|
|
x=$(($x+1))
|
|
done
|
|
|
|
printf "The current time is as follows.\nYear: $year\nMonth: $month\nDay: $day\nTime: $time\n"
|
|
|
|
time=`echo $time | cut -b 1,2,3,4`
|
|
year=`echo $year | cut -b 3,4`
|
|
printf "Your date-compatible string for today is: $month$day$time$year\nHere it is again, on its own line:\n$month$day$time$year\n"
|
|
/bin/ssu -- date -u $month$day$time$year
|
|
rm /tmp/date.jnk
|
|
exit
|