Complément UNIX

Cours de complément d'UNIX


Correction du TP2

#!/bin/bash

function afficherMenu()
{
	cat menutp2

	echo "Votre action :"
	read action

	case $action in
		1 )
			date
		   	 ;;
		2 )
			for i in 1 2 3 4 5
			do
				wget http://www.pobrun.com/tmp/garcons/$i.jpg --output-document=photos/$i.jpg
			done
		    	;;
		3 )
			./tp1.sh
		    	;;
		4 )
			rm puzzles/*.jpg
			nphoto=$((RANDOM%5+1))
			convert photos/$nphoto.jpg -crop 3x3@  +repage  +adjoin  puzzles/%d.jpg
			;;
		5 )
			firefox puzzles/puzzle.html
			;;
		6 )
			ddate
			;;
	esac


	continuer


}

function continuer()
{
	echo "Voulez-vous réafficher le menu ? (y/n)"
	read suite

	case $suite in
		'n' )
			exit;
		    ;;
		'y' )
		    afficherMenu
		    ;;
		* )
		    echo "je ne comprend pas"
		    continuer
		    ;;
	esac
}

afficherMenu