0

This is not quite working right.

#!/bin/bash
[ ! $1 ] && { echo -e "Error!! No time given.!!"; exit 1; }
seamonkey
sleep $1
killall seamonkey

7/20/18

#!/bin/bash
#
# Originally by pavlos_kairis
#
# Open Seamonkey for a specified amount of time and then terminate program
if [ $# -eq 0 ]; then
  echo "Error! no time given."
  echo "Syntax:"
  echo 
  echo "15s = 15 seconds"
  echo "1m = 1 minute"
  echo "1h = 1 hr"
  exit 1
fi
echo "Opening Seamonkey ..."
seamonkey  &
sleep $1
echo "Seamonkey will close in " $1
killall seamonkey
David Foerster
  • 35,754
  • 55
  • 92
  • 145
fixit7
  • 2,776
  • 3
  • 30
  • 70
  • 5
    Take a look at the `timeout` command - no sense re-inventing the wheel here – steeldriver Jul 19 '18 at 22:39
  • 1
    ... as top why it's *"not quite working right"* (terrible problem description btw) if `seamonkey` runs in the foreground, then it doesn't even start to sleep until `seamonkey` terminates – steeldriver Jul 19 '18 at 22:48
  • #!/bin/bash # # Originally by pavlos_kairis # if [ $# -eq 0 ]; then echo "Error! no time given." echo "Syntax:" echo echo "15s = 15 seconds" echo "1m = 1 minute" echo "1h = 1 hr" exit 1 fi echo "Opening Seamonkey ..." seamonkey & sleep $1 echo "Seamonkey will close in " $1 killall seamonkey – fixit7 Jul 20 '18 at 16:02

0 Answers0