Linux Automation & Timers Bash Script Examples
Page 1 of 1
Linux Automation & Timers Bash Script Examples
- Code:
#!/bin/sh
# example: ./Fig_Timer.sh 1 Means 1 Minute Countdown!
#
# sudo apt install figlet
#
#
if [ $# -ne 1 ]; then
echo "usage: $0 MIN (example: $0 1)";
exit 1;
fi
TIME=$(($1*60))
CUR=$TIME
while [ $CUR -gt 0 ]
do
CUR=$(($CUR - 1))
clear
echo $CUR | figlet
sleep 1
done
echo "!!!FINISHED!!!"
Re: Linux Automation & Timers Bash Script Examples
Vid
shellhacks.com/create-ascii-text-banner-linux-command-line
- Code:
#!/bin/bash
#
# ./external_font.sh
#
#
wget http://www.figlet.org/fonts/univers.flf
figlet -f univers.flf "lol"
shellhacks.com/create-ascii-text-banner-linux-command-line
Linux Bash Countdown Script Fall Back For Null User Input
Null User Input Fall Back
- Code:
#!/bin/sh
# example: ./Run_countdown_Test.sh
#
if [ -z "$1" ] && [ -z "$2" ];then
echo "Enter Minutes To Count Down To:"
read var
sh Run_countdown.sh $var
fi
if [ $# -ne 1 ]; then
echo "usage: $0 MIN (example: $0 1)";
exit 1;
fi
TIME=$(($1*60))
CUR=$TIME
while [ $CUR -gt 0 ]
do
CUR=$(($CUR - 1))
clear
echo $CUR | figlet
sleep 1
done
clear
echo "!!!FINISHED!!!"
sh Programs.sh
Re: Linux Automation & Timers Bash Script Examples
Figlet Time & Date
- Code:
#!/bin/bash
# ./date.sh
#
# sudo chmod +x *.sh
#
#
date | figlet
Re: Linux Automation & Timers Bash Script Examples
Linux Bash Clock Figlet Script
- Code:
#!/bin/bash
# ./date.sh
#
# sudo chmod +x *.sh
#
# date --help
#
#
#now=$(date +"%m-%d-%Y") # USA Style
#
now=$(date +"%d-%m-%Y %T") # UK Style
clear
#date | figlet
echo $now | figlet
sleep 1
sh date.sh
Espeak & Figlet Alarm Clock Program Launcher
Espeak & Figlet Alarm Clock Program Launcher
Linux Bash Automation
Alarm.sh
Code:
programs.sh
Buzzer.sh
Linux Bash Automation
- Code:
sudo apt install -y beep mpg123 espeak
- Code:
sudo chmod +x *.sh
Alarm.sh
Code:
- Code:
#!/bin/bash
# A simple alarm clock script
echo "What time should the alarm go off? (HH:MM)"
read target
# sleep interval is 15 minutes
snooze=`dc -e "15 60 *p"`
# convert wakeup time to seconds
target_h=`echo $target | awk -F: '{print $1}'`
target_m=`echo $target | awk -F: '{print $2}'`
target_s_t=`dc -e "$target_h 60 60 ** $target_m 60 *+p"`
# get current time and convert to seconds
clock=`date | awk '{print $4}'`
clock_h=`echo $clock | awk -F: '{print $1}'`
clock_m=`echo $clock | awk -F: '{print $2}'`
clock_s=`echo $clock | awk -F: '{print $3}'`
clock_s_t=`dc -e "$clock_h 60 60 ** $clock_m 60 * $clock_s ++p"`
# calculate difference in times, add number of sec. in day and mod by same
sec_until=`dc -e "24 60 60 **d $target_s_t $clock_s_t -+r%p"`
echo "The alarm will go off at $target." | figlet
sleep $sec_until
# snooze loop
while :
do
#echo -e "\nWake up!"
./buzzer.sh & exit
exit
bpid=$!
disown $bpid # eliminates termination message
read -n1 input
for bsub in $(ps -o pid,ppid -ax | \
awk "{ if (\$2 == $bpid) { print \$1 }}")
do
kill $bsub # kill children
done
kill $bpid
if [ "$input" == "Q" ]
then
#echo -e "\nGood morning!"
exit
else
echo -e "\nSnoozing for $snooze seconds..."
sleep $snooze
fi
done
programs.sh
- Code:
#!/bin/bash
ls
Buzzer.sh
- Code:
#!/bin/bash
#
# ./alarm.sh
#
# sudo apt install -y afplay
# Buzzer script for alarm.sh
# The afplay utility is specific to Mac OS X 10.5 and later.
#while :
#do
# Mac OS
#afplay /System/Library/Sounds/Hero.aiff
# Linux OS
# sudo apt install -y beep mpg123
# sh programs.sh
# out of loop
# 10 Second Wake Up Call
# c=10; while [ $c -ge 0 ]; do espeak $c; let c--; done; sleep 1
clear
msg="Target Time Reached!"
echo "$msg" | figlet
espeak "$msg"
echo "Running Programs..." | figlet
sh programs.sh
exit
# sleep 1
#done
Last edited by jamied_uk on 27th May 2017, 02:11; edited 2 times in total
Re: Linux Automation & Timers Bash Script Examples
Other Help:
got clone github.com/mkscrg/alarm-clock.git
github.com/mkscrg/alarm-clock
askubuntu.com/questions/277215/make-a-sound-once-process-is-complete
got clone github.com/mkscrg/alarm-clock.git
github.com/mkscrg/alarm-clock
askubuntu.com/questions/277215/make-a-sound-once-process-is-complete
Similar topics
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
» Stenography With Linux Script Examples
» Linux Bash Nmap Netmask Notation Examples
» Convert MP4 To MP3 Linux Bash Script
» BASH Linux Talking IP Script
» Stenography With Linux Script Examples
» Linux Bash Nmap Netmask Notation Examples
» Convert MP4 To MP3 Linux Bash Script
» BASH Linux Talking IP Script
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum