Salut
Voici mon pb :
Sous linux en commande bash cette ligne marche nikel :
Citation :
ifconfig ppp0 | grep inet | awk '{print $2}' | awk -F \":\" '{print $2}'
|
j'ai bien l'IP de ma connexion ADSL.
Hors quand j'exécute l'un de c'est script en Perl :
Citation :
#! /usr/bin/perl
$ip = exec("ifconfig ppp0 | grep inet | awk '{print $2}' | awk -F \":\" '{print $2}'" );
print "$ip\n";
|
Citation :
#! /usr/bin/perl
$ip = system("ifconfig ppp0 | grep inet | awk '{print $2}' | awk -F \":\" '{print $2}'" );
print "$ip\n";
|
Citation :
#! /usr/bin/perl
$ip = `ifconfig ppp0 | grep inet | awk '{print $2}' | awk -F ":" '{print $2}'`;
print "$ip\n";
|
j'obtiens toujours le même résultat :
Citation :
inet addr:193.253.62.197 P-t-P:193.253.62.1 Mask:255.255.255.255
|
pk?
certain me dirons : "bou le nul, il c meme pas programmer ! tiens une solus pour un nase :"
Code :
- #! /usr/bin/perl
- $ip =`ifconfig ppp0 | grep inet`;
- if( $ip =~ /inet\s+addr:([\d\.]+)/i ) {
- $ip = $1;
- print "$ip\n";
- }
|
ca marche nikel mais ce ne me dit pas pourquoi l'autre ne marche pas
j'ai deja vu ce topic mais il ne m'interresse pas !
http://forum.hardware.fr/forum2.ph [...] subcat=392
Edit : correction d'une enormité !
Message édité par stef_dobermann le 06-05-2003 à 19:26:18
---------------
Tout à commencé par un rêve...