Comment faire pour que variable garde la valeur de 05 et non 5
Bonjour à tous,
Je suis embeter car mes machines sont nommée de la sorte
machine01
machine02
machine03
etc
J'ai un script qui incrémente sw 1 à 15. Donc un écho va aficher ceci
Citation:
1
2
3
4
5
...
14
15
evidemment, je ne pourrais pas faire un scp sur les machines 01 à 09.
Donc quand ma variable NB=01 va incrémenter. elle va passer de
et évidemment. j'aimerais avoir
Citation:
01
02
03
04
05
...
14
15
Y-a-t-il une astuce pour avoir ce j'ai besoin?
Voici un exemple de mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
DOMAIN=en-node
HOSTN_f=05 #Hostname of the First node (Master)
#becarefull node09 to node12 do not belong to WI.
#The script will escape thos nodes
HOSTN_l=16 #Hostname of the Last node
echo ""
echo "**********************************************"
echo "Get remote ECDSA key finger and copy"
echo "to ~/.ssh/known_hosts"
echo "**********************************************"
echo ""
echo ""
echo "Check if we are on the master node"
echo "====="
hostname -s
if [ $(hostname -s) = $DOMAIN$HOSTN_f ]; then
echo "You run the script from $USER@$DOMAIN$HOSTN_f :)"
else
echo "You must run the script from $DOMAIN$HOSTN_f :("
echo "WARNING: The script exits"
echo ""
echo ""
exit
fi
echo ""
cd ~/.ssh
pwd
#NB=$((HOSTN_f+1))
NB=$HOSTN_f
NBL=$((HOSTN_l+1))
T=10
while [ $NB -lt $NBL ]; do
if [ $NB -eq 9 ]; then
NB=13
fi
if [ $NB -eq 10 ]; then
NB=13
fi
if [ $NB -eq 11 ]; then
NB=13
fi
if [ $NB -eq 12 ]; then
NB=13
fi
echo "DEBUG $NB"
#ssh-keyscan -t rsa node$NB >> ~/.ssh/known_hosts
#ssh-keyscan -t rsa inode$NB >> ~/.ssh/known_hosts
#if [ $NB -lt $T ]; then
# ssh-keyscan -t rsa $USER@$DOMAIN0$NB.epfl.ch >> ~/.ssh/known_hosts
#else
# ssh-keyscan -t rsa $USER@$DOMAIN$NB.epfl.ch >> ~/.ssh/known_hosts
#fi
NB=$((NB+1))
done
echo ""
echo ""
echo "DONE"
echo ""
#less known_hosts
echo ""
echo ""
echo "" |