<![CDATA[Forum Ubuntu-fr.org / [RESOLU] Récupérer adresse IP dans script shell]]> http://forum.ubuntu-fr.org/viewtopic.php?id=1193081 Fri, 08 Feb 2013 13:28:33 +0000 FluxBB <![CDATA[Réponse à : [RESOLU] Récupérer adresse IP dans script shell]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=12508301#p12508301 Ah oui, super.

Merci smile

]]>
Fri, 08 Feb 2013 13:28:33 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=12508301#p12508301
<![CDATA[Réponse à : [RESOLU] Récupérer adresse IP dans script shell]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=12507161#p12507161 hello
dans un tableau

$ IFS="." ip=($1)
$ echo ${ip[@]}
192 168 1 2
]]>
Fri, 08 Feb 2013 11:46:19 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=12507161#p12507161
<![CDATA[[RESOLU] Récupérer adresse IP dans script shell]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=12506571#p12506571 Bonjour à tous,

je suis en train de travailler sur un script shell qui stockerait dans 4 variables différentes une adresse IP fournie en argument.

J'aimerais ce genre de comportement :

$ ./classe.sh 192.168.1.2
octet 1 : 192
octet 2 : 168
octet 3 : 1
octet 4 : 2

Voici le code que j'ai crée et qui semble marcher :

#!/bin/sh
IFS="."

read IP1 IP2 IP3 IP4 << FIN
$1
FIN

echo "Octet 1 : $IP1"
echo "Octet 2 : $IP2"
echo "Octet 3 : $IP3"
echo "Octet 4 : $IP4"

Qu'en pensez-vous ? Avez-vous des solutions plus élégantes en tête ?

Merci d'avance smile

Donut

]]>
Fri, 08 Feb 2013 10:52:32 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=12506571#p12506571