[Linux-bruxelles] tj un chti problème de cut

Jean-Marc jean--marc at belgacom.net
Ven 3 Oct 19:53:56 CEST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aldo a écrit :
> Hello,
> 
> j'essaye d'obtenir la sortie de la commande suivante, sans succès; 
> j'applique pourtant des formules aprises grâce à vous ici, mais je
> dois faire une connerie qq part... Même quand je place ailleur les `
> ` ça le fais pas. Je précise que c'est dans un script que ça se
> passe:
> 
> # Récup de l'indicatif (suffixe) de son pays: cty="`whois `wget -O -
> -q http://www.whatismyip.org/` |grep country: |cut -d: -f2 |cut -c9-
> |tr A-Z a-z`" ou cty="`whois wget -O - -q http://www.whatismyip.org/
> |grep country: |cut -d: -f2 |cut -c9- |tr A-Z a-z`" ou au départ: 
> cty="whois `wget -O - -q http://www.whatismyip.org/` |grep country:
> |cut -d: -f2 |cut -c9- |tr A-Z a-z"
> 
> ne marche pas; j'obtiens l'affichage de la commande à partir de
> whois...
> 
> Mea culpa, mais où est ma faute ?
> 
> Aldo.
> 
Alors, pour commencer, voici ce que j'obtiens après quelques essais chez
moi :
jim:~> wget -O - -q http://www.whatismyip.org Error: 10 requests
received from your IP address in the last 60 seconds (current max is
3 but automated agents should not query more often than once every 10
minutes)

Donc, attention à ce que retourne certaines commandes.  Au bout du
compte, si tu t'attends à recevoir un code pays, c'est largement raté.

Sinon, sur base de mon IP, voilà comment j'ai procédé :
jim:~> cty=$(whois $(<ici le wget>)|awk '/country/{print $2}'|tr
[:upper:] [:lower:])
jim:~> echo $cty
be

J'espère t'avoir aidé.

Jean-Marc
- -----
http://jim.brubel.net/
jim at jabber.belnet.be
- -----
1 personne sur 10 comprend le binaire.  L'autre pas.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFI5lwhjjwCFwSMer0RAoxmAJ9mBSeHBDRV+wowvCR71R2pCAIFhwCgu0G0
gthPw7xLIqJCqCj5QMGErxc=
=/NYA
-----END PGP SIGNATURE-----




Plus d'informations sur la liste de diffusion Linux-bruxelles