in reply to get default gateway

#!/usr/bin/perl -w $|++; open( N, "route |") or die "$!\n"; my @out = (<N>); foreach my $line (@out){ my @words = split(/\s+/,$line); if($words[0] eq 'default'){ print "default-> $words[1]\n"; } }

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: get default gateway
by cyclist38 (Hermit) on Feb 09, 2006 at 22:38 UTC
    remember that with route, ifconfig and so, unless you are root, you need the path. it's not a bad idea to use the path with this sort of app in any case.

      Actually unless you have /sbin in PATH you should use the full path.</pedant>

        Thank you to all for your help, very kind - code pointers and others have enlightened me. Many thanks, Rob.