Download Untitled
Transcript
12.1.8. Exemplo de script de shell com zenity Aqui está um script simples que cria uma imagem ISO com dados RS02 fornecidos por dvdisaster(1). #!/bin/sh -e # gmkrs02 : Copyright (C) 2007 Osamu Aoki <[email protected]>, Public Domain #set -x error_exit() { echo "$1" >&2 exit 1 } # Initialize variables DATA_ISO="$HOME/Desktop/iso-$$.img" LABEL=$(date +%Y%m%d-%H%M%S-%Z) if [ $# != 0 ] && [ -d "$1" ]; then DATA_SRC="$1" else # Select directory for creating ISO image from folder on desktop DATA_SRC=$(zenity --file-selection --directory \ --title="Select the directory tree root to create ISO image") \ || error_exit "Exit on directory selection" fi # Check size of archive xterm -T "Check size $DATA_SRC" -e du -s $DATA_SRC/* SIZE=$(($(du -s $DATA_SRC | awk '{print $1}')/1024)) if [ $SIZE -le 520 ] ; then zenity --info --title="Dvdisaster RS02" --width 640 --height 400 \ --text="The data size is good for CD backup:\\n $SIZE MB" elif [ $SIZE -le 3500 ]; then zenity --info --title="Dvdisaster RS02" --width 640 --height 400 \ --text="The data size is good for DVD backup :\\n $SIZE MB" else zenity --info --title="Dvdisaster RS02" --width 640 --height 400 \ --text="The data size is too big to backup : $SIZE MB" error_exit "The data size is too big to backup :\\n $SIZE MB" fi # only xterm is sure to have working -e option # Create raw ISO image rm -f "$DATA_ISO" || true xterm -T "genisoimage $DATA_ISO" \ -e genisoimage -r -J -V "$LABEL" -o "$DATA_ISO" "$DATA_SRC" # Create RS02 supplemental redundancy xterm -T "dvdisaster $DATA_ISO" -e dvdisaster -i "$DATA_ISO" -mRS02 -c zenity --info --title="Dvdisaster RS02" --width 640 --height 400 \ --text="ISO/RS02 data ($SIZE MB) \\n created at: $DATA_ISO" # EOF Você pode desejar criar um lançador no ambiente de trabalho com um conjunto de comandos algo como "/usr/local/bin/gmkrs02 %d". 12.2. Make O Make é um utilitário para manutenção de grupos de programas Após a execução do make(1), o make lê o ficheiro de regras, "Makefile", e actualiza um alvo se depender de ficheiros pré-requisitados que foram modificados desde que o alvo foi modificado por último, ou se o alvo não existir. A execução destas actualizações pode ocorrer concorrentemente. A regra de sintaxe do ficheiro é a seguinte.