Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

petit script bash

3 réponses
Avatar
fifi774
Bonjour la liste,

J'aimerais créer un script qui test les connexion sur mon serveur avec telnet.
J'aimerais que cela soit automatiser avec un script.

Voila l'idée
Demarrer un connexion telent sur l'ip 127.0.0.1 et le ports 21
si cela repond affiche ok sinon affiche nok

Voila un debut de script

#!/bin/sh
host=127.0.0.1
port=21
cmd="nat list"
if !(telnet ${host} ${port} > /dev/nul)
then
echo "ok"
else
echo "nok"
fi

Mais cela ne fonctionne pas

Si quelqu'un a une idée.

Merci par avance et bonne journée

Philippe


--
Lisez la FAQ de la liste avant de poser une question :
http://wiki.debian.net/?DebianFrench
Vous pouvez aussi ajouter le mot ``spam'' dans vos champs "From" et
"Reply-To:"

To UNSUBSCRIBE, email to debian-user-french-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

3 réponses

Avatar
Fred
On Thursday 18 January 2007 08:00, Fred wrote:
On Thursday 18 January 2007 07:31, wrote:
> Bonjour la liste,
>
> J'aimerais créer un script qui test les connexion sur mon serveur avec
> telnet. J'aimerais que cela soit automatiser avec un script.
>
> Voila l'idée
> Demarrer un connexion telent sur l'ip 127.0.0.1 et le ports 21
> si cela repond affiche ok sinon affiche nok
>
> Voila un debut de script
>
> #!/bin/sh
> host7.0.0.1
> port!
> cmd="nat list"
> if !(telnet ${host} ${port} > /dev/nul)
> then
> echo "ok"
> else
> echo "nok"
> fi
>
> Mais cela ne fonctionne pas
>
> Si quelqu'un a une idée.

Tu devrais regarder du coté de expect[1]

[1] http://expect.nist.gov/

Tu y trouveras probablement ton bonheur.



J'ajouterai la page sur wikipedia[2] qui donne des exemples simples
d'utilisation.

[2] http://en.wikipedia.org/wiki/Expect

J'espere que ça t'aidera.

Fred.
Avatar
Fred
On Thursday 18 January 2007 07:31, wrote:
Bonjour la liste,

J'aimerais créer un script qui test les connexion sur mon serveur avec
telnet. J'aimerais que cela soit automatiser avec un script.

Voila l'idée
Demarrer un connexion telent sur l'ip 127.0.0.1 et le ports 21
si cela repond affiche ok sinon affiche nok

Voila un debut de script

#!/bin/sh
host7.0.0.1
port!
cmd="nat list"
if !(telnet ${host} ${port} > /dev/nul)
then
echo "ok"
else
echo "nok"
fi

Mais cela ne fonctionne pas

Si quelqu'un a une idée.



Tu devrais regarder du coté de expect[1]

[1] http://expect.nist.gov/

Tu y trouveras probablement ton bonheur.

Fred.
Avatar
Glennie Vignarajah
--nextPart2073827.oItgEF6VJL
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Le Thursday 18 January 2007 07:31, () a
écrit:
Bonjour la liste,


Bonsoir,

J'aimerais créer un script qui test les connexion sur mon serveur
avec telnet. J'aimerais que cela soit automatiser avec un script.
Voila un debut de script



Utilisez plutôt netcat pour ça!


#!/bin/sh
host7.0.0.1
port!
cmd="nat list"
if !(telnet ${host} ${port} > /dev/nul)



Remplacez cette ligne par

if [ "$(nc -z ${host} ${port} ; echo $?)" = "0" ]

then
echo "ok"
else
echo "nok"
fi


A+


--
Glennie
"Qui veut faire quelque chose trouve un moyen, qui ne veut rien faire
trouve une excuse."

--nextPart2073827.oItgEF6VJL
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iQEVAwUARbE499HiioqkksXaAQL1vAgAhHU2J6JZXS1VTnMtYiVschVZz+2gUmDR
w7FznCtcOdfDZMTNcZ550WeiSUwaH2gtG8WB/9LF9Mmt6/t8XVCptDdwg29/pKAR
Ijeeil6T9v2NmojHGce49hF6CPFTx4Fix7zM36uKNLVMSrdkmhouqfUy1wzr+tu4
w9zL3y/EtgMLyP5xVsDR3g8q47BM4hPuT5Z/qYnFBwjDTjc3xsZCyavwBg0PDjZN
k2sP5+C4H9ZJsVmQg9vBG2BNnCp1mNY1B0Ic67BFoBV8uvRbKEVQMU+tZb6GZ36s
cArqkjhm5Fpn4FhmkUyjHy+TRwiO5zUp6/Y/7MyJe4DOz6ZPQkY9Qg= =h5qD
-----END PGP SIGNATURE-----

--nextPart2073827.oItgEF6VJL--


--
Lisez la FAQ de la liste avant de poser une question :
http://wiki.debian.net/?DebianFrench
Vous pouvez aussi ajouter le mot ``spam'' dans vos champs "From" et
"Reply-To:"

To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact