From 52ceef28623c2d49264e3e3eb29f7d4bc0acaca2 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 28 Aug 2014 16:25:37 +0200 Subject: [PATCH] use first ip if eth0 is not available --- scripts/RFID-JSONP-server.pl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/RFID-JSONP-server.pl b/scripts/RFID-JSONP-server.pl index f29c638..62a2d79 100755 --- a/scripts/RFID-JSONP-server.pl +++ b/scripts/RFID-JSONP-server.pl @@ -305,19 +305,20 @@ sub rfid_register { foreach ( split(/\n/, `ip addr` ) ) { if ( /^\d:\s(\w+):\s/ ) { - $ip->{last} = $1; + $ip->{_last} = $1; } elsif ( /^\s+inet\s((\d+)\.(\d+)\.(\d+)\.(\d+))\/(\d+)/ ) { - $ip->{ $ip->{last} } = $1; + $ip->{ $ip->{_last} } = $1; } else { - warn "# SKIP [$_]\n"; + #warn "# SKIP [$_]\n"; } - } + warn dump($ip); + my $ua = LWP::UserAgent->new; my $url = URI->new( $rfid_url . '/register.pl'); $url->query_form( - local_ip => $ip->{eth0}, + local_ip => $ip->{eth0} || $ip->{ (keys %$ip)[0] }, ); warn "GET ",$url->as_string; my $response = $ua->get($url); -- 2.20.1