in reply to How can I check if the eth? exist

You didn't specify what OS you are on, but it looks like you are running on Linux given you are looking for "eth?".

Here is a sniglet that I pulled out of an RC script of mine running on RH 9.0 and therefore tested on RH 9.0. There is enough common stuff here that it should run on any flavor of *nix and revolves around the netstat -i command invokation.

#!/usr/bin/perl -w ################################ use strict; open(PIPE,'netstat -i|') or die $!; my $header=<PIPE>; # Kernel Interface Table $header=<PIPE>; # The real header chomp $header; # # Oh... what the hey... Let's parse it just for grins. my @fields=split(/[\s]+/,$header); my %ifTable=(); # Set up an empty assoc array while (my $line=<PIPE>){ chomp $line; my @f=split(/[\s]+/,$line); foreach my $ix(1..$#f){ $ifTable{$f[0]}->{$fields[$ix]}=$f[$ix]; } } # # But wait... you just wanted the IF names: printf "%s\n",join(",",keys %ifTable);

when I ran it on my laptop (another flavor of Linux other than where it usually runs) it not only worked portably but I got the following:
vmnet1,lo,wlan0,vmnet8,eth0

Now, this lists the interfaces, if you wanted to just determine the existance of an interface you could also do something like:
: : much handwaving here my @results=grep /eth1/,`netstat -i`; : : I didn't test that, but should work... :

Using my much wordier code you could (instead of printing) also do:
: : print "It's there\n" if $ifTable{'eth1'}; # or whatever : :

Hope this is of some small use to you...