Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 02/05/2012, à 17:36

PowaBanga

Un bash qui est pris en compte de façon incomplète

Bonjour,
je me suis lancé dans la création d'un bash pour installer automatiquement un jeu wine sur son pc graphiquement, et avec tous les messages d'erreur possible, seulement voilà, mon bash ne marche pas, et quand le le copie/colle dans la console, je me rend compte que le collage est incomplet, il y a carément des endroits ou plusieurs mots on disparut yikes.

Voici mon bash, il n'est pas encore finalisé, je ne sais pas si ça fait la même chose chez vous, perso je ne comprend pas du tout à quoi cela peut-être dû.... sad

#/bin/bash
(
####step1####
echo "02" ; sleep 1
echo "# Intro" ; sleep 1
    echo "This program will install DDay Normandy on you pc by using line command and with wine. If wine is not installed on your computer, stop this to install it ! 

DDay: Normandy is a free FPS game on the second world war. You can find more informations and support on this site : [url=http://www.ddaydev.com]www.ddaydev.com[/url].

If you have a problem during the game you can repport it on the bug tracer :
[url=http://www.ddaydev.com/bugtracker/]www.ddaydev.com/bugtracker/[/url]
If you have a problem during the installation, you can contact Lio on the IRC support if I am in, on the french site :
 [url=http://www.ddaynormandy-fr.com]www.ddaynormandy-fr.com[/url]
or by mail via this page :
[url=http://www.ddaynormandy-fr.com/contact]www.ddaynormandy-fr.com/contact[/url]

About the support irc you can connect it via this page, put #ddayhome in channel :
webchat.quakenet.org/?uio=MTE9MTMz98
or via a client with the server irc.quakenet.org" > $HOME/DDstep1
zenity --text-info \
       --title='Installation: D-Day: Normandy, Step 1' \
--filename=$HOME/DDstep1 \
       --checkbox='Wine is installed on my computer.'
if [ "$?" = 1 ] ; then
zenity --error \
--title "Wine is not installed" \
--no-wrap \
--text="    You say that wine is not 
installed on your computer. :o
    Ok, I stop this installer :)
       Come back when it
         will be installed ;)"
exit 1
fi
if [ "$?" = -1 ] ; then
zenity --error \
--no-wrap \
--text="    You say that wine is not 
installed on your computer. :o
    Ok, I stop this installer :)
       Come back when it
         will be installed ;)"
exit 1
fi
if [ "$?" -eq 0 ]; then
rm -rf  $HOME/DDstep
#####Création des fichiers#####

echo "07" ; sleep 1
echo "#Create directories and files" ; sleep 1



##     bash  recherche installateur       ##
##     Step2       ##
echo 'zenity --question \
--no-wrap \
--text="If you have not already downloaded 
  the installer.exe of the game, this 
       programe can do for you.
  Click YES to download the game, 
  or NO to select among your files"
if [ "$?" -eq 1 ]; then
bash $HOME/step2Ch
fi
if [ "$?" -eq 0 ]; then
bash $HOME/step2D
fi
if [ "$?" -eq -1 ]; then
zenity --error \
--text="-1"
fi
' > $HOME/setp2
##     Step2D       ##
echo '(
mkdir -p $HOME/.applications/win/Games/dday
cd $HOME/.applications/win/Games/dday
echo "0";  sleep 1; 
wget -v [url]http://ubuntuone.com/4QTK2lJPmxfyelOkLHoeCs[/url]
echo "100"; sleep 1;
if [ "$?" -eq 4 ]; then
rm -rf $HOME/.applications/win/Games/dday
zenity --error \
 --no-wrap \
--auto-kill \
--title="Can not resolve connection" \
--text=" We can not resolve the connection.
Make you sure that your computer
is connected on your network"
bash $HOME/step2Ch
fi
if [ "$?" -eq 8 ]; then
rm -rf $HOME/.applications/win/Games/dday
zenity --error \
 --no-wrap \
--auto-kill \
--title="Bad destination" \
--text="The url to download the game is wrong.
    Please repport that to Lio :)"
bash $HOME/step2Ch
fi
if [ "$?" -eq -1 ]; then
rm -rf $HOME/.applications/win/Games/dday
zenity --error \
--title="I fuck the errors " \
 --no-wrap \
--text="Occured Error
 Into STEP2D
    héé fait chier..."
fi
if [ "$?" -eq 0 ]; then
mv 4QTK2lJPmxfyelOkLHoeCs install.exe
fi
)| zenity --title="Copie de fichiers" --progress --auto-close --pulsate --auto-kill --text="The game is being downloaded in your user folder.
 The file is 217 MB and 560 MB when extracted.
 To stop the current download, click on cancel."' > $HOME/step2D
##     Step2Ch       ##
echo 'mkdir -p $HOME/.applications/win/Games/dday
installer=`zenity --file-selection --title "File" --save`
if [ "$?" -eq 1 ]; then
#123456#
zenity --question \
 --no-wrap \
 --title="Do you want stop ?" \
--text="You have not selected file
Do you want stop the installation ? "
    if [ "$?" -eq 0 ]; then
exit 1
     elif [ "$?" -eq 1 ]; then
bash Step2
     else
zenity --error \
 --no-wrap \
--text=" occured error
to comment 123456
        in step2Ch"
       fi
elif [ "$?" -eq 0 ]; then
mv "$installer" $HOME/.applications/win/Games/dday/installer.exe

else
zenity --error \
 --no-wrap \
--text="                 RHAAAA !
    Putain de merde !
erreur inconnue dans le 
         STEP2CH !
Planquez vous ça va barder..."
fi' > $HOME/step2Ch

#WINE#
echo "
export WINEPREFIX='$HOME/.applications/win/Games/dday/wineprefix'
cd $HOME/.applications/win/Games/dday
wine 'install.exe'
mv $HOME/.applications/win/Games/dday/wineprefix/drive_c/D-Day\ Normandy $HOME/.applications/win/Games/dday
rm -rf $HOME/.applications/win/Games/dday/install.exe" > $HOME/step3

    


echo "48" ; sleep 1
echo "# Look for the game" ; sleep 1
bash $HOME/step2
if [ "$?" = -1 ] ; then
echo "60" ; sleep 1
echo "#Error during the search..."
fi
if [ "$?" = 0 ] ; then
echo "60" ; sleep 1
echo "#The download was stopping"
fi
#si non on continue#
####step3####
echo "95" ; sleep 1
echo "# Instalation via wine" ; sleep 1
bash $HOME/step3
echo "95" ; sleep 1
echo "# Start files -- launcher wine" ; sleep 1
#create launcher for the game#
echo "export WINEPREFIX="$HOME/.applications/win/Games/dday/wineprefix"
cd $HOME/.applications/win/Games/dday/D-Day\ Normandy
wine 'D-Day Launcher.exe' " > $HOME/.applications/win/Games/dday/D-Day\ Launcher\ Forlinux
chmod +x $HOME/.applications/win/Games/dday/D-Day\ Launcher\ Forlinux
chmod +x $HOME/.applications/win/Games/dday/D-Day\ Normandy/D-Day\ Launcher.exe
##refresh serverlist.cfg##
echo "96" ; sleep 1
echo "# Start files -- serverlist" ; sleep 1
rm -rf  $HOME/.applications/win/Games/dday/D-Day\ Normandy/dday/serverlist.cfg
echo 'set adr0 "99.190.136.76:27910"
set adr1 "24.63.162.196:27910"
set adr2 "99.190.136.76 :72910"
set adr3 "201.238.222.123:27911"
set adr4 "201.238.222.123:27910"
set adr5 "70.77.177.252:27910"
set adr6 "70.77.177.252:27910"
set adr7 "24.63.162.49:27910"
set adr8 "178.33.42.103:27910"
set adr9 ""
' > $HOME/.applications/win/Games/dday/D-Day\ Normandy/dday/serverlist.cfg
#create a shortuct .descktop file#
echo "96" ; sleep 1
echo "# Start files -- shortcut" ; sleep 1
echo "[Desktop Entry]
Encoding=UTF-8
Name=D-Day: Normandy
Comment=D-Day: Normandy
Type=Application
Exec=$HOME/.applications/win/Games/dday/D-Day\ Launcher\ Forlinux
Icon=$HOME/.applications/win/Games/dday/D-Day\ Normandy/dday/dday_icon.ico
Categories=Game;ArcadeGame;" > $HOME/.local/share/applications/D-Day_Normandy.desktop
#to ask and create launcher in /usr/bin if the user accept#
echo "97" ; sleep 1
echo "# Start files -- launcher /user/bin" ; sleep 1
zenity --question \
 --no-wrap \
--title="DDay Binaire" \
--text='  Do you want to have a launcher 
 to launch the game in a console ? 
   This will ask your password !
     And it will create simply a 
 launcher named "ddaynormandy"
              in "/usr/bin"
Click on "No" if you do not want this'
if [ "$?" -eq 0 ]; then  
echo "echo '$HOME/.applications/win/Games/dday/D-Day\ Launcher\ Forlinux' > /usr/bin/ddaynormandy
chmod +x /usr/bin/ddaynormandy" > $HOME/.applications/win/Games/dday/bin
chmod +x $HOME/.applications/win/Games/dday/bin
gksu bash $HOME/.applications/win/Games/dday/bin
rm -rf $HOME/.applications/win/Games/dday/bin
fi
echo "98" ; sleep 1
echo "# Start files -- launcher wine" ; sleep 1
zenity --question \
--no-wrap \
--title="DDay Setting.txt" \
--text=" Do you want install the
        French config ?
This will translate setting.txt
  into French, and configure
    the game for Azerty
            keyboard."
if [ "$?" -eq 0 ]; then
cd $HOME/.applications/win/Games/dday/D-Day\ Normandy/Settings.txt
rm -rf $HOME/.applications/win/Games/dday/D-Day\ Normandy/Settings.txt
wget [url]http://www.archive-host.com/count-1573390-Settings.txt[/url]
mv count-1573390-Settings.txt Settings.txt
fi



echo "99" ; sleep 1
echo "# Delete install files" ; sleep 1
rm -rf step2 step2D step2Ch step3
echo "100" ; sleep 1
echo "# The installation is finished" ; sleep 1
) |
zenity --progress \
  --title="Install..DDay." \
  --text="Initialisation..." \
  --percentage=0

if [ "$?" = 1 ] ; then
zenity --error \
--text="Installation stopped."
fi

Édit :
ici j'ai déjà pas corrigé mon script, j'ai refait le test en racourcicant mon script, et j'ai quand même cette erreur, ça empêche tout simplement l'exécution de mon script globalement regardez, je fai trois fichiers textes dès le début, et au troisième il veux pas me mettre le "> $HOME/step2Ch"

echo "02" ; sleep 1
echo "# Intro" ; sleep 1
    echo "This program will install DDay Normandy on you pc by using line command and with wine. If wine is not installed on your computer, stop this to install it ! 

DDay: Normandy is a free FPS game on the second world war. You can find more informations and support on this site : [url=http://www.ddaydev.com]www.ddaydev.com[/url].

If you have a problem during the game you can repport it on the bug tracer :
[url=http://www.ddaydev.com/bugtracker/]www.ddaydev.com/bugtracker/[/url]
If you have a problem during the installation, you can contact Lio on the IRC support if I am in, on the french site :
 [url=http://www.ddaynormandy-fr.com]www.ddaynormandy-fr.com[/url]
or by mail via this page :
[url=http://www.ddaynormandy-fr.com/contact]www.ddaynormandy-fr.com/contact[/url]

About the support irc you can connect it via this page, put #ddayhome in channel :
webchat.quakenet.org/?uio=MTE9MTMz98
or via a client with the server irc.quakenet.org" > $HOME/DDstep1
zenity --text-info \
       --title='Installation: D-Day: Normandy, Step 1' \
--filename=$HOME/DDstep1 \
       --checkbox='Wine is installed on my computer.'
if [ "$?" = 1 ] ; then
rm -rf  $HOME/DDstep
zenity --error \
--title "Wine is not installed" \
--no-wrap \
--text="    You say that wine is not 
installed on your computer. :o
    Ok, I stop this installer :)
       Come back when it
         will be installed ;)"
exit 1
fi
if [ "$?" = -1 ] ; then
rm -rf  $HOME/DDstep
zenity --error \
--no-wrap \
--text="    You say that wine is not 
installed on your computer. :o
    Ok, I stop this installer :)
       Come back when it
         will be installed ;)"
exit 1
fi
if [ "$?" -eq 0 ]; then
rm -rf  $HOME/DDstep
fi
#####Création des fichiers#####

echo "07" ; sleep 1
echo "#Create directories and files" ; sleep 1



##     bash  recherche installateur       ##
##     Step2       ##
echo 'zenity --question \
--no-wrap \
--text="If you have not already downloaded 
  the installer.exe of the game, this 
       programe can do for you.
  Click YES to download the game, 
  or NO to select among your files"
if [ "$?" -eq 1 ]; then
bash $HOME/step2Ch
fi
if [ "$?" -eq 0 ]; then
bash $HOME/step2D
fi
if [ "$?" -eq -1 ]; then
zenity --error \
--text="-1"
fi
' > $HOME/step2
##     Step2D       ##
echo '(
mkdir -p $HOME/.applications/win/Games/dday
cd $HOME/.applications/win/Games/dday
echo "0";  sleep 1; 
wget -v [url]http://ubuntuone.com/4QTK2lJPmxfyelOkLHoeCs[/url]
echo "100"; sleep 1;
if [ "$?" -eq 4 ]; then
rm -rf $HOME/.applications/win/Games/dday
zenity --error \
 --no-wrap \
--auto-kill \
--title="Can not resolve connection" \
--text=" We can not resolve the connection.
Make you sure that your computer
is connected on your network"
bash $HOME/step2Ch
fi
if [ "$?" -eq 8 ]; then
rm -rf $HOME/.applications/win/Games/dday
zenity --error \
 --no-wrap \
--auto-kill \
--title="Bad destination" \
--text="The url to download the game is wrong.
    Please repport that to Lio :)"
bash $HOME/step2Ch
fi
if [ "$?" -eq -1 ]; then
rm -rf $HOME/.applications/win/Games/dday
zenity --error \
--title="I fuck the errors " \
 --no-wrap \
--text="Occured Error
 Into STEP2D
    héé fait chier..."
fi
if [ "$?" -eq 0 ]; then
mv 4QTK2lJPmxfyelOkLHoeCs install.exe
fi
)| zenity --title="Copie de fichiers" --progress --auto-close --pulsate --auto-kill --text="The game is being downloaded in your user folder.
 The file is 217 MB and 560 MB when extracted.
 To stop the current download, click on cancel."' > $HOME/step2D
##     Step2Ch       ##
echo 'mkdir -p $HOME/.applications/win/Games/dday
installer=`zenity --file-selection --title "File" --save`
if [ "$?" -eq 1 ]; then
#123456#
zenity --question \
 --no-wrap \
 --title="Do you want stop ?" \
--text="You have not selected file
Do you want stop the installation ? "
    if [ "$?" -eq 0 ]; then
exit 1
     elif [ "$?" -eq 1 ]; then
bash Step2
     else
zenity --error \
 --no-wrap \
--text=" occured error
to comment 123456
        in step2Ch"
       fi
elif [ "$?" -eq 0 ]; then
mv "$installer" $HOME/.applications/win/Games/dday/installer.exe

else
zenity --error \
 --no-wrap \
--text="                 RHAAAA !
    Putain de merde !
erreur inconnue dans le 
         STEP2CH !
Planquez vous ça va barder..."
fi' > $HOME/step2Ch

Dernière modification par PowaBanga (Le 02/05/2012, à 18:02)

Hors ligne

#2 Le 03/05/2012, à 00:17

Hicham_ASR

Re : Un bash qui est pris en compte de façon incomplète

Bonsoir,
je crois qu'il faut mettre filename="$HOME/DDstep1", essayes de mettre le chemin de fichier en tant que chaîne de caractères peut-être que c'est là le problème.
j'espère que ça va t'aider parce que lors de la réalisation d'un quelconque script soit avec bash ou sh la majorité des problèmes sont causés par la mauvaise manipulation des chemins et des chaînes de caractères.

Hors ligne

#3 Le 03/05/2012, à 00:57

Watael

Re : Un bash qui est pris en compte de façon incomplète

salut,

quand le le copie/colle dans la console,

mais pourquoi fais-tu ça ?


Connected \o/
Welcome to sHell. · eval is evil.

Hors ligne

#4 Le 03/05/2012, à 17:00

PowaBanga

Re : Un bash qui est pris en compte de façon incomplète

en fait le step 1 c'est encore le seul truc qui fonctionne bien,
si je l'ai copié/collé dans la console, c'était pour essayer de trouver les erreurs
En attendant j'ai totalement démonté mon script pour le réécrire, et j'ai enlevé la barre de progression globale pour pouvoir chercher les erreur de step en step.
j'ai mis toutes les echo de création de fichier texte au début, donc si le problème persiste je vous tiendrais au courant smile

Hors ligne

#5 Le 03/05/2012, à 17:53

twocats

Re : Un bash qui est pris en compte de façon incomplète

Je te propose cette version, libre à toi de la modifier. Par contre wine n'installe rien, aucune réaction, à toi de me dire pourquoi :

#!/usr/bin/env bash

set -x
set -o pipefail

shopt -s nocaseglob

INPUT_FILE=${INPUT_FILE:-dday_install.exe}
PID_OF=$$

IntroBOX()
{
cat << EOF >> "${HOME}"/introbox.${PID_OF}
This program will install DDay Normandy on you pc by using line command and with wine. If wine is not installed on your computer, stop this to install it ! 

DDay: Normandy is a free FPS game on the second world war. You can find more informations and support on this site :
http://www.ddaydev.com

If you have a problem during the game you can repport it on the bug tracer :
http://www.ddaydev.com/bugtracker/

If you have a problem during the installation, you can contact Lio on the IRC support if I am in, on the french site :
http://www.ddaynormandy-fr.com]www.ddaynormandy-fr.com
or by mail via this page :
http://www.ddaynormandy-fr.com/contact

About the support irc you can connect it via this page, put #ddayhome in channel :
webchat.quakenet.org/?uio=MTE9MTMz98
or via a client with the server irc.quakenet.org
EOF

zenity --text-info --height=500 --width=600 \
--title="Installation: D-Day: Normandy, Step 1" \
--filename="${HOME}"/introbox.${PID_OF}
rm -f "${HOME}"/introbox.${PID_OF}
}

CheckDepBOX()
{
# Tests des dépendances
for PROG_REQ in wget wine
do
    if [[ ! "$(type -p ${PROG_REQ} 2>/dev/null)" ]]
    then
        zenity --error --title="Installation: D-Day: Check dependencies" \
        --text="${PROG_REQ} is not installed \!\nI stop this installer.\nCome back when it will be installed."
        exit 1
    fi
done
}

DownloadBOX()
{
( echo 10
echo "# Download in progress.\nPlease wait..."
wget -v http://ubuntuone.com/4QTK2lJPmxfyelOkLHoeCs
echo 50
echo "# Download in progress.\nDone..."
mv 4QTK2lJPmxfyelOkLHoeCs "${OUTPUT_DIR}"/"${INPUT_FILE}"
echo 100
) | zenity --progress --auto-close --title="Installation: D-Day: Download" --width="400" --pulsate || exit
}

MenuBOX()
{
CHOICE_VALUE=$(zenity --height=150 --width=350 --list --radiolist \
--title="Installation: D-Day: Download and Install" \
--text="Select your choice in the menu." \
--hide-header \
--hide-column 2 \
--column="" \
--column="" \
--column="" \
TRUE 1 "Download the game and install" \
FALSE 2 "Select the install file and install") || exit

case ${CHOICE_VALUE} in
    1 ) SelectOutputDirBOX;DownloadBOX; WineBOX ;;
    2 ) SelectFileBOX; SelectOutputDirBOX; WineBOX ;;
esac
}

SelectFileBOX()
{
INPUT_FILE=$(zenity --file-selection --title="Select the install file") || exit
}

SelectOutputDirBOX()
{
OUTPUT_DIR=$(zenity --file-selection --directory --title="Select destination folder") || exit
[[ ${CHOICE_VALUE} -eq 2 ]] && mv "${INPUT_FILE}" "${OUTPUT_DIR}"
}

WineBOX()
{
zenity --question --title="Installation: D-Day" --text="Install D-Day: Normandy NOW \?"
case $? in
    0) "${TERM}" -geometry 170x40 -T "Installation: D-Day" -e wine "${OUTPUT_DIR}"/"${INPUT_FILE##*/}" ;;
    1) exit ;;
    -1) exit ;;
esac
}

IntroBOX
CheckDepBOX
MenuBOX

La réponse est 42

Hors ligne

#6 Le 03/05/2012, à 19:05

PowaBanga

Re : Un bash qui est pris en compte de façon incomplète

Franchement j'adore ton script, y me fait bander mdr, comme quoi j'ai encore beaucoup à aprendre smile

Mais chez moi ton script plante quand je choisi de télécharger le jeu (parce que quand je le choisi dans mes dossiers, tout va très bien, même wine... hmm

...
+ MenuBOX
++ zenity --height=150 --width=350 --list --radiolist '--title=Installation: D-Day: Download and Install' '--text=Select your choice in the menu.' --hide-header --hide-column 2 --column= --column= --column= TRUE 1 'Download the game and install' FALSE 2 'Select the install file and install'
+ CHOICE_VALUE=1
+ exit
lio@Karkatouf:~/Public$ echo $?
139
lio@Karkatouf:~/Public$ 

Alors j'ai un peu cherché à comprendre ton script, et dans la downloadbox, je m'aperçois que "${INPUT_FILE}" ne signifie rien...
je me trompe ? si je ne me trompe pas il doit être remplacé par un vide de texte ou provoquer une erreur...
Je ne devrais pas donner une signification pour que ca marche ? on fait comment ?
genre :
${INPUT_FILE}=installer.exe

Hors ligne

#7 Le 03/05/2012, à 20:38

twocats

Re : Un bash qui est pris en compte de façon incomplète

Peut-tu recommencer en te plaçant dans le répertoire du script après l'avoir rendu exécutable de cette manière :

./le_nom_du_script > log.txt

et me donner le contenu du fichier log.txt.

Dernière modification par twocats (Le 03/05/2012, à 20:39)


La réponse est 42

Hors ligne