# Finalisation script BASH besoin d'un peut d'aide

**URL:** <https://www.debian-fr.org/t/finalisation-script-bash-besoin-dun-peut-daide/33924>\
**Category:** Programmation\
**Created:** [Février 21, 2016, 3:23 UTC](https://www.debian-fr.org/t/finalisation-script-bash-besoin-dun-peut-daide/33924 "2016-02-21T03:23:01Z")\
**Posts on this page:** 3\
**Page:** 3

<div class="post-metadata">

**Author:** ![Totor](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/t/58f4c7/32.png) [@Totor](https://www.debian-fr.org/u/Totor)\
**Post date:** [Février 21, 2016, 3:30 UTC](https://www.debian-fr.org/t/finalisation-script-bash-besoin-dun-peut-daide/33924/41 "2016-02-21T03:30:30Z")

</div>

huum… j’ai une petite idée :  
ne lancerais-tu pas ton script ainsi ?

```auto

```

auquel cas, c’est normal que la syntaxe ne soit pas reconnue puisque tu utilises dash !

---

<div class="post-metadata">

**Author:** ![chris38](https://www.debian-fr.org/user_avatar/www.debian-fr.org/chris38/32/12918_2.png) [@chris38](https://www.debian-fr.org/u/chris38)\
**Post date:** [Février 21, 2016, 3:30 UTC](https://www.debian-fr.org/t/finalisation-script-bash-besoin-dun-peut-daide/33924/42 "2016-02-21T03:30:40Z")

</div>

[quote=“Totor”]huum… j’ai une petite idée :  
ne lancerais-tu pas ton script ainsi ?

```auto

```

auquel cas, c’est normal que la syntaxe ne soit pas reconnue puisque tu utilises dash ![/quote]  
Non, c’est bash…

[code]#!/bin/bash  
REPERTOIRE\_SOURCE="/data/Photos\_reduites"  
rep\_absent="!!!..Attention, Le repertoire source n’éxiste pas …!!!“  
rep\_vide=“Votre repertoire est vide, ajoutez vos fichiers et renouveler l’opération.“  
DATE=`date +%d%m%y`  
VERT=”\033[1;32m"  
NORMAL=”\033[0;39m"  
ROUGE=”\033[1;31m"  
ROSE="\033[1;35m"  
BLEU="\033[1;34m"  
BLANC="\033[0;02m"  
BLANCLAIR="\033[1;08m"  
JAUNE="\033[1;33m"  
CYAN="\033[1;36m"  
echo “Teste de la présence du répertoire ou sont stocké les photos à réduire"  
echo “Veuillez patienter quelques instant"  
sleep 2  
if [! -e “$REPERTOIRE\_SOURCE”]  
then  
echo “$ROUGE””$rep\_absent” “$NORMAL"  
sleep 2  
echo “Veuillez créer le repertoire suivant : “$VERT””$REPERTOIRE\_SOURCE”" “$NORMAL"  
echo “Fermeture du programme"  
sleep 2  
exit  
fi  
echo -n “$BLEU”“Nombre de fichiers à traiter” :  
var=$(ls -a “$REPERTOIRE\_SOURCE” | grep -cv ‘.$’)  
echo “$VERT””$var"  
sleep 2  
if [$var -eq 0]  
then  
echo “$ROUGE””$rep\_vide""$NORMAL"  
echo "Fermeture du programme"  
sleep 5  
exit  
fi  
###################################  
title="Choisissez la résolution d’image souhaité’“  
imgsize=`zenity --title "$title" --list --separator=" " --column="size" "160x120" "320x240" "640x480" "800x600" "1024x768"`  
if [“$?” != 0] ; then  
exit  
fi  
#user have to select target size  
#imgsize=`echo $imgsize | sed 's/ max//g'`  
imgsize=$ {imgsize/ max/}  
if [! “$imgsize”]; then  
zenity --error --title=“error” --text=“select a target size"  
exit  
fi  
#To respect proportions  
himgsize=$imgsize  
#val1=`echo "$imgsize" | awk -F'x' '{ print $1 }'`  
val1=”${imgsize##x\*}“  
imgsize=”${val1}x${val1}”  
###################################

echo “$JAUNE”“Les photos du répertoire courant : “$VERT” “$REPERTOIRE\_SOURCE” “$NORMAL”, vont être redimenssionnées aux valeurs suivantes :”$VERT" “$imgsize”""$NORMAL"  
sleep 2  
cd “$REPERTOIRE\_SOURCE"  
date=”$(date +%d\_%m\_%Y)"  
mkdir -p "$date"  
indice=$(printf ‘%s\n’ $_date/$date\*|awk -F[_.] ’ $6 \> num { num=$6 } END { print num+1 } ')  
printf ‘%s\n’ _._|egrep -i ‘.(jpg|png|tiff|bmp)$’|while read I ; do  
echo “Redimensionnement de : $VERT $I $NORMAL"  
ext=”${I##\*.}“  
ext=”${ext,}“  
out=”$date/${date}\_$indice.$ext"  
convert -filter Cubic -resize $imgsize $I “$out”  
((indice++))  
done[/code]

---

<div class="post-metadata">

**Author:** ![Totor](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/t/58f4c7/32.png) [@Totor](https://www.debian-fr.org/u/Totor)\
**Post date:** [Février 21, 2016, 3:30 UTC](https://www.debian-fr.org/t/finalisation-script-bash-besoin-dun-peut-daide/33924/43 "2016-02-21T03:30:45Z")

</div>

> [@chris38](#):
>
> Non, c’est bash…

![:naughty:](https://www.debian-fr.org/uploads/default/original/1X/a8041fe32d5c63bbc6616e748e6b50af85839764.gif "Naughty") Ce n’est pas parce que tu précises bash au shebang que le script est forcément exécuté avec bash !

C’est pour cela que je te demande la façon dont tu le lances !  
si tu mets sh avant le nom de ton script, c’est sh qui l’interprète, et non bash😒

[Page précédente](https://www.debian-fr.org/t/finalisation-script-bash-besoin-dun-peut-daide/33924.md?page=2)
