From 04b076b7909d468fc01ba84bd3c4ac3bc4e26f27 Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Mon, 16 Dec 2013 15:59:41 +0100 Subject: [PATCH] =?UTF-8?q?Test=20select=20and=20completed=20=C3=96vning?= =?UTF-8?q?=205,=20labb=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Labb5/ovning5.sh | 12 ++++++++---- Misc/test_select.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100755 Misc/test_select.sh diff --git a/Labb5/ovning5.sh b/Labb5/ovning5.sh index 71e09ec..0f36991 100755 --- a/Labb5/ovning5.sh +++ b/Labb5/ovning5.sh @@ -5,18 +5,20 @@ # Övning 5, labb 5 # Backup-script -# Sanity checks - # Set some variabels BackupTo="$HOME/backups/" +# Set our binarys +Tar="/bin/tar" + # Sanity checks if [ $# -ne 1 ]; then echo "Usage: $0 " + exit 2 fi -if [ -w $BackupTo ]; then - echo "Can't write to $BackupTo" > /dev/stderr +if [ ! -w $BackupTo ] || [ ! -d $BackupTo ]; then + echo "Can't write to $BackupTo or doesn't exist" > /dev/stderr exit 2 fi @@ -26,4 +28,6 @@ if [ ! -r "$1" ]; then fi # Main +$Tar cvf ${BackupTo}`basename $1`.tar $1 +exit 0 diff --git a/Misc/test_select.sh b/Misc/test_select.sh new file mode 100755 index 0000000..1b6f4b8 --- /dev/null +++ b/Misc/test_select.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Jack-Benny Persson +# LX13 +# Testing select, thx Paulena :) + +select Word in "Ja" "Nej" "Kanske" "Exit"; do + echo $Word + case "$Word" in + Ja) + echo "Omg YES" + ;; + Nej) + echo "Oh no" + ;; + Kanske) + echo "Maybe later baby" + ;; + Exit) + echo "Se ya later" + exit 0 + ;; + esac +done + +exit 0