in reply to pattern matching difficulties, in two cases

It would be a lot more accurate to write two different expressions, one for each OS and then just have your script check which OS it is running on and use the appropriate regex.

$sunifconfig=qr/blahblahblah/; $linuxifconfig=qr/blahblahblah/; if ($^O eq "linux"){ $ifconfigoutput=~/$linuxifconfig/; } else { $ifconfigoutput=~/$sunifconfig/; }

*That code is untested.

Fellow monks, I don't know if using the $^O ($OSNAME) variable is the right way to go here. Feel free to comment.

HTH

Replies are listed 'Best First'.
Re: Re: patern matching difficulties, in two cases
by waswas-fng (Curate) on Jun 24, 2003 at 18:58 UTC
    Make sure you specify the full path to ifconfig as well, you will not that solaris has a few versions of it and they have different outputs.

    /sbin/ifconfig interface [ address_family ] [ address [ dest_address ] ] [ up ] [ down ] [ auto-revarp ] [ net- mask mask ] [ broadcast address ] [ metric n ] [ mtu n ] [trailers | -trailers ] [private | -private ] [arp | -arp ] [ plumb ] [ unplumb ] /usr/sbin/ifconfig interface [ address_family ] [ address [ dest_address ] ] [ up ] [ down ] [ auto-revarp ] [ netmask mask ] [ broadcast address ] [ metric n ] [ mtu n ] [trailers | -trailers ] [private | -private ] [arp | -arp ] [ plumb ] [ unplumb ] /sbin/ifconfig interface {auto-dhcp | dhcp } [ primary ] [ wait seconds ] drop | extend | ping | release | start | status /usr/sbin/ifconfig interface {auto-dhcp | dhcp } [ pri- mary ] [ wait seconds ] drop | extend | ping | release | start | status


    -Waswas
      thank you very much for that information, it is most helpful
      jcpunk

      by the way thanks for all the help that was, is, and will be

Re: Re: patern matching difficulties, in two cases
by jcpunk (Friar) on Jun 24, 2003 at 19:15 UTC
    thank you for that idea, i did not know that the $^O existed, and i will definatly look into that
    jcpunk

    by the way thanks for all the help that was, is, and will be