[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: problème de tableau sous bash exécuté par cron



Le 27/03/2010 20:11, Jeremie COURREGES-ANGLAS a écrit :
Le samedi 27 mars 2010 à 06:57:31, Philippe R a écrit :
voici un example pour tester :

voici ma ligne cron :
*/1 * * * *     root    /etc/scripts/test.sh
(cela me donne de temps de changer en live la partie qui "merdouille" ....)
voici mon script :
#!/bin/sh
1) Que fait le 'root' sur cette ligne cron ?
La commande exécutée ici est 'root /etc/scripts/test.sh'.
Perso je n'ai pas de commande 'root' sur mes debian :)
'*/1' est équivalent à '*'.
=> désolé oui c est vrai :)
2) Ton script devrait avoir pour première ligne :

#!/bin/bash
=> oui c est vrai j ai changé
...

En effet un shell POSIX comme dash ne supporte pas les tableaux.
Tu ne devrais pas faire la supposition que /bin/sh est un lien vers bash.
Sinon, tu peux construire le même tableau ainsi :

Array=( '' filemgr-all newsletter phpmyadmin ... )
=> j ai essaye
Dans un bash / ksh, les tableaux commencent à l'indice zéro.

le retour par mail de mon script:
#!/bin/sh
#declare -a Array=([1]=filemgr-all [2]=newsletter [3]=phpmyadmin
[4]=roundcubemail [5]=tracker [6]=calendrier [7]=ipplan [8]=dspam
[9]=postfix [10]=spam)
Array[1]='filemgr-all'
Array[2]='newsletter'
Array[3]='phpmyadmin'
Array[4]='roundcubemail'
Array[5]='tracker'
Array[6]='calendrier'
Array[7]='ipplan'
Array[8]='dspam'
Array[9]='postfix'
Array[10]='spam'
NbElement=${#Array[*]}
echo $NbElement
echo ${Array[10]}
Le mail que cron t'envoie contient le contenu de ton script ?
Pas de messages d'erreurs, ou autre ?
'fin je pense que ton problème doit être résolu, là.
=> ben non j ai l erreur :

/etc/scripts/test.sh: 7: Syntax error: word unexpected (expecting ")")


voici le contenu total du script lancé :
#!/bin/bash
#Array=([1]=filemgr-all [2]=newsletter [3]=phpmyadmin [4]=roundcubemail [5]=tracker [6]=calendrier [7]=ipplan [8]=dspam [9]=postfix [10]=spam)
Array('' filemgr-all newsletter )
NbElement=${#Array[*]}
echo $NbElement
echo ${Array[10]}
echo "================"
#env
#declare  toto
#toto=(filemgr-all test)
#NbElement1=${#toto[*]}
#echo $NbElement1
echo titi

Santé !
à la tienne :)
merci  de ta réponse
--
"Free software, free society."
Jérémie Courrèges-Anglas
(New) GPG key : 06A11494




Reply to: