Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Piatok, 19. apríl 2024

Súbor: [Platon] / scripts / shell / firewall / ifconfig-parse.sh (stiahnutie)

Revízia 1.1, Thu Aug 7 08:33:42 2003 UTC (20 years, 8 months ago) by rajo

Script for parsing output from '/sbin/ifconfig'.

#!/bin/sh

#
# ifconfig-parse.sh - parse output from ifconfig and print
#                     in format suitable for eval in shell
#
# Developed by Lubommir Host 'rajo' <rajo AT platon.sk>
# Copyright (c) 2003 Platon SDG
# Licensed under terms of GNU General Public License.
# All rights reserved.
#

# $Platon$

# Parse output from ifconfig:
/sbin/ifconfig | \
    awk 'BEGIN { interfaces=""; }
        /^[a-zA-Z0-9]+/ {
            iface=$1;
            interfaces = sprintf("%s %s", interfaces, iface);
            printf "\nIFACE_%s=\"%s\";\nHWaddr_%s=\"%s\";\nexport IFACE_%s HWaddr_%s\n",
                $1, $1, $1, $5, $1, $1;
        }
        /^[ \t]+inet/ {
            split($0, fields, "[ \t:]+");
            printf "IP_%s=\"%s\";\nBcast_%s=\"%s\";\nMask_%s=\"%s\";\n",
                iface, fields[4],  iface, fields[6],  iface, fields[8];
            printf "export IP_%s Bcast_%s Mask_%s\n",
                iface, iface, iface;
        }
        END { printf "\ninterfaces=\"%s\"\n", interfaces; }
    '


Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok