5 WIP
This commit is contained in:
		
							
								
								
									
										6
									
								
								beispiele/5/01-vars.sh
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								beispiele/5/01-vars.sh
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -5,4 +5,8 @@ X=20            #variables are case sensitive
 | 
			
		||||
$y=             #NULL variable
 | 
			
		||||
echo "x = $x"
 | 
			
		||||
echo "X = $X"
 | 
			
		||||
echo "y = $y"
 | 
			
		||||
echo "y = $y"
 | 
			
		||||
 | 
			
		||||
unset x
 | 
			
		||||
echo "x = $x"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										0
									
								
								beispiele/5/02-comments.sh
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								beispiele/5/02-comments.sh
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										8
									
								
								beispiele/5/03-quoting.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								beispiele/5/03-quoting.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
echo 'Ticks "schützen" Anführungszeichen' 
 | 
			
		||||
 | 
			
		||||
echo "Ist dies ein \"Sonderfall\"?" 
 | 
			
		||||
 | 
			
		||||
echo "Sie haben `ls | wc -l` Dateien in `pwd`" 
 | 
			
		||||
 | 
			
		||||
echo "Der Wert von \$x ist $x" 
 | 
			
		||||
							
								
								
									
										16
									
								
								beispiele/5/04-function-exitcode.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								beispiele/5/04-function-exitcode.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
count2 () {
 | 
			
		||||
      if [ -d "$1" ]; then   # überprüfen, ob der erste Parameter ein Verzeichnis ist
 | 
			
		||||
         ls $1 | wc -l       # wie oben
 | 
			
		||||
         exit 0            # alles OK
 | 
			
		||||
      else
 | 
			
		||||
         echo "Ungültiges Verzeichnis: $1"
 | 
			
		||||
         exit 1            # Fehler
 | 
			
		||||
      fi
 | 
			
		||||
}
 | 
			
		||||
count2 "/gibt/es/garnicht"  # Aufrufe der Funktion count2
 | 
			
		||||
echo "Status: $?"
 | 
			
		||||
 | 
			
		||||
count2 "/etc"
 | 
			
		||||
echo "Status: $?"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										13
									
								
								beispiele/5/04-function.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										13
									
								
								beispiele/5/04-function.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 
 | 
			
		||||
fatal() {
 | 
			
		||||
     msg=$1
 | 
			
		||||
     echo "Fatal: $msg"
 | 
			
		||||
     exit 1
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
[ -d /tmp ] || fatal "Verzeichnis /tmp existiert nicht"
 | 
			
		||||
[ -w /tmp ] || fatal "Verzeichnis /tmp nicht schreibbar"
 | 
			
		||||
 
 | 
			
		||||
TMP=/tmp/mydir
 | 
			
		||||
[ -d $TMP ] || mkdir $TMP    # tmp-Verz. erzeugen, wenn noch nicht vorhanden
 | 
			
		||||
							
								
								
									
										0
									
								
								beispiele/5/recursive-func.sh → beispiele/5/05-recursive-func.sh
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								beispiele/5/recursive-func.sh → beispiele/5/05-recursive-func.sh
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										9
									
								
								beispiele/5/06-dialog.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								beispiele/5/06-dialog.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
# Set PS3 prompt
 | 
			
		||||
PS3="Enter the space shuttle to get more information : "
 | 
			
		||||
 | 
			
		||||
# set shuttle list
 | 
			
		||||
select shuttle in columbia endeavour challenger discovery atlantis enterprise pathfinder
 | 
			
		||||
do
 | 
			
		||||
    echo "$shuttle selected"
 | 
			
		||||
done
 | 
			
		||||
							
								
								
									
										48
									
								
								beispiele/5/07-select-menu.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								beispiele/5/07-select-menu.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
# Set PS3 prompt
 | 
			
		||||
PS3="Enter the space shuttle to get more information : "
 | 
			
		||||
 | 
			
		||||
# set shuttle list
 | 
			
		||||
select shuttle in columbia endeavour challenger discovery atlantis enterprise pathfinder
 | 
			
		||||
do
 | 
			
		||||
    case $shuttle in
 | 
			
		||||
		columbia)
 | 
			
		||||
			echo "--------------"
 | 
			
		||||
			echo "Space Shuttle Columbia was the first spaceworthy space shuttle in NASA's orbital fleet."
 | 
			
		||||
			echo "--------------"
 | 
			
		||||
			;;
 | 
			
		||||
		endeavour)
 | 
			
		||||
			echo "--------------"		
 | 
			
		||||
			echo "Space Shuttle Endeavour is one of three currently operational orbiters in the Space Shuttle." 
 | 
			
		||||
			echo "--------------"		
 | 
			
		||||
			;;
 | 
			
		||||
		challenger) 
 | 
			
		||||
			echo "--------------"				
 | 
			
		||||
		    echo "Space Shuttle Challenger was NASA's second Space Shuttle orbiter to be put into service."
 | 
			
		||||
			echo "--------------"				    
 | 
			
		||||
			;;		
 | 
			
		||||
		discovery) 
 | 
			
		||||
			echo "--------------"		
 | 
			
		||||
			echo "Discovery became the third operational orbiter, and is now the oldest one in service."
 | 
			
		||||
			echo "--------------"							
 | 
			
		||||
			;;		
 | 
			
		||||
		atlantis)
 | 
			
		||||
			echo "--------------"		
 | 
			
		||||
			echo "Atlantis was the fourth operational shuttle built."
 | 
			
		||||
			echo "--------------"							
 | 
			
		||||
			;;
 | 
			
		||||
		enterprise)
 | 
			
		||||
			echo "--------------"		
 | 
			
		||||
			echo "Space Shuttle Enterprise was the first Space Shuttle orbiter."
 | 
			
		||||
			echo "--------------"							
 | 
			
		||||
			;;		
 | 
			
		||||
		pathfinder)
 | 
			
		||||
			echo "--------------"		
 | 
			
		||||
			echo "Space Shuttle Orbiter Pathfinder is a Space Shuttle simulator made of steel and wood."
 | 
			
		||||
			echo "--------------"							
 | 
			
		||||
			;;
 | 
			
		||||
		*)		
 | 
			
		||||
			echo "Error: Please try again (select 1..7)!"
 | 
			
		||||
			;;		
 | 
			
		||||
	esac
 | 
			
		||||
done
 | 
			
		||||
							
								
								
									
										0
									
								
								beispiele/5/while-menu.sh → beispiele/5/08-while-menu.sh
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								beispiele/5/while-menu.sh → beispiele/5/08-while-menu.sh
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										36
									
								
								beispiele/5/09-backup.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								beispiele/5/09-backup.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# Get date in dd-mm-yyyy format
 | 
			
		||||
NOW="$(date +"%d-%m-%Y")"
 | 
			
		||||
 | 
			
		||||
function file_backup {
 | 
			
		||||
	wpbackupfile="wordpress-backup-$NOW.tar.gz"
 | 
			
		||||
    oxidbackupfile="oxid-back-$NOW.tar.gz"
 | 
			
		||||
 | 
			
		||||
	echo 'WP Files Backup --- building tar File...'
 | 
			
		||||
	tar -czf $wpbackupfile ~/www/rvv/wp*
 | 
			
		||||
	echo '+DONE'
 | 
			
		||||
	
 | 
			
		||||
    echo 'oxid  Files Backup --- building tar File...'
 | 
			
		||||
	tar -czf $oxidbackupfile ~/www/rvv/shop
 | 
			
		||||
	echo '+DONE'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function oxid_db_backup {
 | 
			
		||||
    host=localhost
 | 
			
		||||
    user=rvv
 | 
			
		||||
    pass=xxxxxxxxx
 | 
			
		||||
    db=webshop
 | 
			
		||||
 | 
			
		||||
	echo 'oxid DB Export ------> '
 | 
			
		||||
	mysqldump --opt --add-drop-table -h$host -u$user -p$pass $db | gzip > oxid-db-$NOW.sql.gz
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
backupdir=~/backup
 | 
			
		||||
cd ~ ; mkdir $backupdir ; cd $backupdir
 | 
			
		||||
 | 
			
		||||
oxid_db_backup
 | 
			
		||||
file_backup
 | 
			
		||||
 | 
			
		||||
# delete old backups
 | 
			
		||||
find /home/dany/backups -mtime +10 -type f -delete
 | 
			
		||||
							
								
								
									
										6
									
								
								beispiele/5/aufgabe1.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										6
									
								
								beispiele/5/aufgabe1.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
OUTFILE="liste.txt"
 | 
			
		||||
liste=`ls | tee $OUTFILE `
 | 
			
		||||
echo $liste
 | 
			
		||||
 | 
			
		||||
cat $OUTFILE
 | 
			
		||||
		Reference in New Issue
	
	Block a user