logo Debian Debian Debian-France Debian-Facile Debian-fr.org Forum-Debian.fr Debian ? Communautés logo inclusivité

Debian-facile

Bienvenue sur Debian-Facile, site d'aide pour les nouveaux utilisateurs de Debian.

Vous n'êtes pas identifié(e).

#1 22-03-2011 22:09:15

mecanotox
Membre
Distrib. : Ubuntu 16.04 LTS
Noyau : 4.15.0-15-generic
(G)UI : Unity 7
Inscription : 04-06-2008

[Shell Bash] Erreur scripte

Salut à tous.

#################################

### Scripte Convertisseur Video                #

#################################

#!/bin/bash

echo '########################################'

echo '[!]Utilisation de ffmpeg[!]'

echo '[!]Verifiez que ffmpeg soit installer[!]'

echo '########################################'

echo '[c1] Convertion Format PSP'

echo '[c2] Convertion Format Platine DVD'

echo '[Q] Quitter'

read -p 'Saisissez votre choix :' rep

if [ $rep ='c1' ]

    then

        echo 'Utilitaire de Convertion AVI en MP4 pour PSP'

        read -p 'Saisissez le fichier source (Attention : *.avi ou *.mp4) :' fichier_src

        read -p 'Saisissez le fichier de destination (Attention : *.avi ou *.mp4):' fichier_dest

        echo '[f1] Tout Firmware (Custome Firmware ou Originale) Qualite SD'

        echo '[f2] Firmware inferieur a 3.71 (Custome Firmware ou Originale) Qualite MQ'

        echo '[f3] Firmware superieur a 3.71 (Custome Firmware ou Originale) Qualite HD'

        read -p 'Saisissez votre version de firmware PSP (Conseil : Utilisez choix [f3])' firmware

        if [ $firmware = 'f1' ]

            then

                echo 'Encodage Video Format PSP Tout Firmware [DEMARRAGE] Qualite SD'

                # ffmpeg -i $fichier_src -b 300 -s 320×240 -vcodec xvid -ab 32 -ar 24000 -acodec aac $fichier_dest

                echo 'Encodage Video Format PSP Tout Firmware [TERMINE] Qualite SD'

        elif [ $firmware = 'f2' ]

            then

                echo 'Encodage Video Format PSP Firmware < 3.71 [DEMARRAGE] Qualite MQ'

                # ffmpeg -i $fichier_src -f psp -r 29.97 -b 768k -ar 24000 -ab 64k -s 480x160 $fichier_dest

                echo 'Encodage Video Format PSP Firmware < 3.71 [TERMINE]Qualite MQ'

        elif [ $firmware = 'f3' ]

            then

                echo 'Encodage Video PSP Firmware > 3.71 [DEMARRAGE] Qualite HD'

                # ffmpeg -i $fichier_src -r 29.97 -vcodec h264 -s 640x480 -aspect 16:9 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -b 768k -maxrate 1500k -bufsize 4M -bt 256k -refs 1 -bf 3 -coder 1 -me umh -me_range 16 -subq 7 -partitions +parti4x4+parti8x8+partp8x8+partb8x8 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -qcomp 0.6 -trellis 2 -sc_threshold 40 -i_qfactor 0.71 -acodec aac -ab 112k -ar 48000 -ac 2 -s 480x272 -aspect 4:3 $fichier_dest

                echo 'Encodage Video PSP Firmware > 3.71 [TERMINE] Qualite HD'

        else

            then

                echo 'Erreur - Choix Invalide'

        fi

elif [ $rep = 'c2' ]

    then

        echo 'Saisissez le fichier source (Attention : *.avi ou *.mp4)'

        read -p fichier_src

        echo 'Saisissez le fichier de destination (Attention : *.mpeg)'

        read -p fichier_dest

        echo 'Encodage Video Format Platine DVD [DEMARRAGE]'

        # ffmpeg -i $fichier_src -target pal-dvd -ps 2000000000 -aspect 16:9 $fichier_dest

        echo 'Encodage Video Format Platine DVD [TERMINE]'


Je suis en train de faire un petit scripte pour mon utilisation perso, pour ainsi garder en mémoire dans un scriptes certaines commandes ffmpeg.

Suelement voilà, il semblerais que le scripte cloche à la ligne "read -p 'Saisissez votre choix :' rep" et à "elif [ $firmware = 'f2' ]"

Avez vous une petite solution pour mon souci de code ?

Hors ligne

#2 25-03-2011 05:57:53

zoroastre74
Membre
Distrib. : Debian Wheezy
Noyau : Linux 3.2
(G)UI : Awesome wm v3.4.13 (Octopus)
Inscription : 28-08-2010

Re : [Shell Bash] Erreur scripte

Yep!

Beaucoup d'erreur d'indentation, peut-être dû à l'export !!!
Bien respecter les espaces entre les crochets et le signe égal dans les blocs conditionnels.

A part çà, sa roule wink

Pour éviter trop de if, regardes du côté de case...


#################################

### Scripte Convertisseur Video                #

#################################

#!/bin/bash

echo '########################################'

echo '[!]Utilisation de ffmpeg[!]'

echo '[!]Verifiez que ffmpeg soit installer[!]'

echo '########################################'

echo '[c1] Convertion Format PSP'

echo '[c2] Convertion Format Platine DVD'

echo '[Q] Quitter'

read -p 'Saisissez votre choix :' rep

if [ "$rep" = "c1" ] ; then
  echo 'Utilitaire de Convertion AVI en MP4 pour PSP'
  read -p 'Saisissez le fichier source (Attention : *.avi ou *.mp4) :' fichier_src
  read -p 'Saisissez le fichier de destination (Attention : *.avi ou *.mp4):' fichier_dest
  echo '[f1] Tout Firmware (Custome Firmware ou Originale) Qualite SD'
  echo '[f2] Firmware inferieur a 3.71 (Custome Firmware ou Originale) Qualite MQ'
  echo '[f3] Firmware superieur a 3.71 (Custome Firmware ou Originale) Qualite HD'
  read -p 'Saisissez votre version de firmware PSP (Conseil : Utilisez choix [f3])' firmware
 
  if [ "$firmware" = "f1" ] ; then
    echo 'Encodage Video Format PSP Tout Firmware [DEMARRAGE] Qualite SD'
    # ffmpeg -i $fichier_src -b 300 -s 320×240 -vcodec xvid -ab 32 -ar 24000 -acodec aac $fichier_dest
    echo 'Encodage Video Format PSP Tout Firmware [TERMINE] Qualite SD'
  elif [ "$firmware" = "f2" ] ; then
    echo 'Encodage Video Format PSP Firmware < 3.71 [DEMARRAGE] Qualite MQ'
    # ffmpeg -i $fichier_src -f psp -r 29.97 -b 768k -ar 24000 -ab 64k -s 480x160 $fichier_dest
    echo 'Encodage Video Format PSP Firmware < 3.71 [TERMINE]Qualite MQ'
  elif [ "$firmware" = "f3" ] ; then
    echo 'Encodage Video PSP Firmware > 3.71 [DEMARRAGE] Qualite HD'
    # ffmpeg -i $fichier_src -r 29.97 -vcodec h264 -s 640x480 -aspect 16:9 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -b 768k -maxrate 1500k -bufsize 4M -bt 256k -refs 1 -bf 3 -coder 1 -me umh -me_range 16 -subq 7 -partitions +parti4x4+parti8x8+partp8x8+partb8x8 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -qcomp 0.6 -trellis 2 -sc_threshold 40 -i_qfactor 0.71 -acodec aac -ab 112k -ar 48000 -ac 2 -s 480x272 -aspect 4:3 $fichier_dest
    echo 'Encodage Video PSP Firmware > 3.71 [TERMINE] Qualite HD'
  else
    echo 'Erreur - Choix Invalide'
  fi

elif [ "$rep" = "c2" ] ; then
  echo 'Saisissez le fichier source (Attention : *.avi ou *.mp4)'
  read -p fichier_src
  echo 'Saisissez le fichier de destination (Attention : *.mpeg)'
  read -p fichier_dest
  echo 'Encodage Video Format Platine DVD [DEMARRAGE]'
  # ffmpeg -i $fichier_src -target pal-dvd -ps 2000000000 -aspect 16:9 $fichier_dest
  echo 'Encodage Video Format Platine DVD [TERMINE]'

elif [ "$rep" = "Q" ] ; then

exit 0

fi

Hors ligne

#3 25-03-2011 07:28:36

zoroastre74
Membre
Distrib. : Debian Wheezy
Noyau : Linux 3.2
(G)UI : Awesome wm v3.4.13 (Octopus)
Inscription : 28-08-2010

Re : [Shell Bash] Erreur scripte

Yep!

Une illustration utilisant case.
Cela me semble plus lisible, aprés c'est aussi une question de gout wink


#################################

### Scripte Convertisseur Video                #

#################################

#!/bin/bash

echo '########################################'
echo '[!]Utilisation de ffmpeg[!]'
echo '[!]Verifiez que ffmpeg soit installer[!]'
echo '########################################'
echo '[c1] Convertion Format PSP'
echo '[c2] Convertion Format Platine DVD'
echo '[Q] Quitter'
read -p 'Saisissez votre choix :' rep

case $rep in
c1)
  echo 'Utilitaire de Convertion AVI en MP4 pour PSP'
  read -p 'Saisissez le fichier source (Attention : *.avi ou *.mp4) :' fichier_src
  read -p 'Saisissez le fichier de destination (Attention : *.avi ou *.mp4):' fichier_dest
  echo '[f1] Tout Firmware (Custome Firmware ou Originale) Qualite SD'
  echo '[f2] Firmware inferieur a 3.71 (Custome Firmware ou Originale) Qualite MQ'
  echo '[f3] Firmware superieur a 3.71 (Custome Firmware ou Originale) Qualite HD'
  read -p 'Saisissez votre version de firmware PSP (Conseil : Utilisez choix [f3])' firmware
 
  case $firmware in
  f1)
    echo 'Encodage Video Format PSP Tout Firmware [DEMARRAGE] Qualite SD'
    # ffmpeg -i $fichier_src -b 300 -s 320×240 -vcodec xvid -ab 32 -ar 24000 -acodec aac $fichier_dest
    echo 'Encodage Video Format PSP Tout Firmware [TERMINE] Qualite SD'
  ;;
  f2)
    echo 'Encodage Video Format PSP Firmware < 3.71 [DEMARRAGE] Qualite MQ'
    # ffmpeg -i $fichier_src -f psp -r 29.97 -b 768k -ar 24000 -ab 64k -s 480x160 $fichier_dest
    echo 'Encodage Video Format PSP Firmware < 3.71 [TERMINE]Qualite MQ'
  ;;
  f3)
    echo 'Encodage Video PSP Firmware > 3.71 [DEMARRAGE] Qualite HD'
    # ffmpeg -i $fichier_src -r 29.97 -vcodec h264 -s 640x480 -aspect 16:9 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -b 768k -maxrate 1500k -bufsize 4M -bt 256k -refs 1 -bf 3 -coder 1 -me umh -me_range 16 -subq 7 -partitions +parti4x4+parti8x8+partp8x8+partb8x8 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -qcomp 0.6 -trellis 2 -sc_threshold 40 -i_qfactor 0.71 -acodec aac -ab 112k -ar 48000 -ac 2 -s 480x272 -aspect 4:3 $fichier_dest
    echo 'Encodage Video PSP Firmware > 3.71 [TERMINE] Qualite HD'
  ;;
  *)
    echo 'Erreur - Choix Invalide'
  esac
;;
c2)
  echo 'Saisissez le fichier source (Attention : *.avi ou *.mp4)'
  read -p fichier_src
  echo 'Saisissez le fichier de destination (Attention : *.mpeg)'
  read -p fichier_dest
  echo 'Encodage Video Format Platine DVD [DEMARRAGE]'
  # ffmpeg -i $fichier_src -target pal-dvd -ps 2000000000 -aspect 16:9 $fichier_dest
  echo 'Encodage Video Format Platine DVD [TERMINE]'
;;
q|Q)

exit 0

;;

*)
  echo "choix non valide"

esac

Dernière modification par zoroastre74 (25-03-2011 07:56:39)

Hors ligne

#4 25-03-2011 09:07:27

mecanotox
Membre
Distrib. : Ubuntu 16.04 LTS
Noyau : 4.15.0-15-generic
(G)UI : Unity 7
Inscription : 04-06-2008

Re : [Shell Bash] Erreur scripte

Merci. Effectivement avec case c'est plus lisible.

Hors ligne

#5 25-03-2011 09:13:00

mecanotox
Membre
Distrib. : Ubuntu 16.04 LTS
Noyau : 4.15.0-15-generic
(G)UI : Unity 7
Inscription : 04-06-2008

Re : [Shell Bash] Erreur scripte

Après je trouve assez sensible la synthaxe sous shell.

J'ai pensé à l'écrire en C (me semble que c'est de base dans linux => gcc, en plus ça me ferais pas mal je pense) mais bon je sais pas si avec C on peu executer des commande sous Shell (Et si c'est possible, finalement n'est-ce pas plus compliqué ?)

Hors ligne

#6 25-03-2011 10:19:31

zoroastre74
Membre
Distrib. : Debian Wheezy
Noyau : Linux 3.2
(G)UI : Awesome wm v3.4.13 (Octopus)
Inscription : 28-08-2010

Re : [Shell Bash] Erreur scripte

Yep!

Quel que soit le langage utilisé, il y aura toujours des erreurs de synthaxe, une virgule mal posée ou autre...L'avantage de travailler avec le C, Vb, etc, se retrouve dans l'utilisation d'un IDE, logiciel qui facilite les taches courantes (auto-completion, coloration, bibliothèque de définitions, ...).

En définitive, il faut toujours favoriser le langage que l'on connait le mieux, au détriment quelque-fois, d'experimentation vers d'autres univers synthaxiques...

Le C est un trés bon choix si tu le maitrises, et tu peux naturellement lancer toutes sortes de commandes avec...(via system() ou mieux encore exec() ou execv()).
Pour ma part, je bidouille plus du C que je ne le programme...

Ps : Si tu veux apprendre à programmer, Python peut remplir tes espérences. Simple et rapide.

@+

Zoroastre.

Hors ligne

#7 25-03-2011 10:50:49

mecanotox
Membre
Distrib. : Ubuntu 16.04 LTS
Noyau : 4.15.0-15-generic
(G)UI : Unity 7
Inscription : 04-06-2008

Re : [Shell Bash] Erreur scripte

J'apprends sur PHP en ce moment. IL se rapproche pas mal de l'algo. Il y a en + MySQL, j'arrive a suivre, mais bon je maitrise pas toutes les bases encore (array, afficher des resultats de requête et ordonner tout ça). Et shell, ba se rapproche de PHP syntaxiquement c'est pour sa que j'arrive un peu a faire des petits scriptes.

Hors ligne

Pied de page des forums