Potrzebuj

Potrzebujesz pomocy z C, C++, perl, python, itp.
mek
Posty: 7
Rejestracja: 31 maja 2015, 15:37

Post autor: mek »

Kod: Zaznacz cały

function choiceA () # Create a backup
{
echo "________________________"
echo "You chose to create a backup, please enter your directory:"

read Directory

if [ -d "$Directory" ]; #cheking directory exist
then 
echo "Chose where to save your backup"
echo "A. Default directory."
echo "B. Chosedi rectory."
read choice2

case "$choice2" in
"A|a" ) # save a backup in directory
tar -zcvf $NAZWA.tar.gz $Directory
echo "The backup has been created."
;;
"B|b" ) #choose where to save
echo "Please enter your choice where to save backup>"
read Directory2 #Deklaracja gdzie zapisac
NOW=$(date +"%F")
NAZWA="Backup-$NOW"
tar -zcvf $Directory2/$NAZWA.tar.gz $Directory  # NOW=$(date +"%F")
echo "The backup has been created ."
;;
* ) echo "Please enter a vaild input."
;;

esac


else
echo "This directory does not exit."
fi
}

function choiceB () #restore a backup
{
echo " You choose to restore a backup."
echo " Where would you like to save your restore file."
echo "A. Default backup diretory."
echo "B. Choose directory."
read choice3 # Declare variable

case "$choice3" in 
A|a )
tar -zxvf $NAZWA.tar.gz
echo "The backup has been restored"
;;
B|b )
echo "Please enter a directory wher is the file you want s"
read Directory3 # Declare Variable
tar -zxvf $Directory3/$NAZWA.tar.gz
echo "The backup has restored."
;;
* )
echo "Please enter a valid input."
;;
esac
} #End function
function choiceC () #Exit the menu
{
echo "You chose to exit the Menu."
}

function display_menu ()
{
clear #clear all commends

echo " Welcome to the program for creating backup and restore her.If you want to exit the program, click the C"
exit="false"
while [ "$exit" = "false" ]
do 
 
echo "A. Default directory."
echo "B. Choose directory."
echo "_______________________" #list menu option
echo "what is your option?"
echo "A. Create a backup"
echo "B. Restore a backup."
echo "C. Quit"
read choice
# See what the user has chooseen
case "$choice" in 
A|a ) choiceA # Start function A
;;
B|b ) choiceB # start function B
;;
C|c ) choiceC #start function Q
     exit
     exit="true"
;;
*) echo "Please enter a valid input."  # if the user enter not valid input
;;
esac
done
}

echo "Please type m to display the menu " # start to the menu
read startmenu
while [ "$startmenu" = "m" ]
do 
display_menu # start function display_menu
done

if [ "$startmenu" != "m" ]
then
echo "You didin't type m. The program is closing."
echo "_____________________________"
fi #end of if
dalej bład
Awatar użytkownika
dedito
Moderator
Posty: 3518
Rejestracja: 18 listopada 2013, 21:07
Lokalizacja: Gliwice

Post autor: dedito »

A ja jestem wróżką i sobie zgadnę jaki to błąd. Daruje sobie dalszy udział w tym wątku.
mek
Posty: 7
Rejestracja: 31 maja 2015, 15:37

Post autor: mek »

Czy może ktoś mi pomóc . :(
ODPOWIEDZ