PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Linux Automation & Timers Bash Script Examples

Go down

Linux Automation & Timers Bash Script Examples Empty Linux Automation & Timers Bash Script Examples

Post by jamied_uk 26th May 2017, 02:15







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!!!"
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Linux Automation & Timers Bash Script Examples Empty Re: Linux Automation & Timers Bash Script Examples

Post by jamied_uk 26th May 2017, 02:36

Vid


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
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Linux Automation & Timers Bash Script Examples Empty Linux Bash Countdown Script Fall Back For Null User Input

Post by jamied_uk 26th May 2017, 17:42

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
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Linux Automation & Timers Bash Script Examples Empty Re: Linux Automation & Timers Bash Script Examples

Post by jamied_uk 26th May 2017, 18:20

jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Linux Automation & Timers Bash Script Examples Empty Re: Linux Automation & Timers Bash Script Examples

Post by jamied_uk 26th May 2017, 20:52

Figlet Time & Date





Code:
#!/bin/bash
# ./date.sh
#
# sudo chmod +x *.sh
#
#
date | figlet
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Linux Automation & Timers Bash Script Examples Empty Re: Linux Automation & Timers Bash Script Examples

Post by jamied_uk 26th May 2017, 21:12

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
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Linux Automation & Timers Bash Script Examples Empty Espeak & Figlet Alarm Clock Program Launcher

Post by jamied_uk 27th May 2017, 02:02

Espeak & Figlet Alarm Clock Program Launcher
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
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Linux Automation & Timers Bash Script Examples Empty Re: Linux Automation & Timers Bash Script Examples

Post by jamied_uk 27th May 2017, 02:06

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
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Linux Automation & Timers Bash Script Examples Empty Re: Linux Automation & Timers Bash Script Examples

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum