Avatar billede zeion Nybegynder
17. februar 2005 - 15:16 Der er 2 kommentarer og
1 løsning

udtræk af enkelte ord fra .txt

Hejsa...

Hvordan få jeg rippet dette text doc så der hvor der står Ethernet0 is up bliver det første up til $var1 , og det næste up til $var2
og så videre ned i dokumenter hvor der står

Ethernet1
Serial0
Serial1

det skal ikke være sådan at den søger på up da up kan blive noget andet i tilfældet af line eller protokol er nede. Så det skal være noget med den søger i linerne.. efter ETHERNET0 is og ligger det der kommer efter og inde kommaet i en $var

Ethernet0 is up, line protocol is up
  Hardware is Lance, address is 0000.0c5c.fe7e (bia 0000.0c5c.fe7e)
  Internet address is 10.1.1.125/30
  MTU 1500 bytes, BW 10000 Kbit, DLY 1000 usec,
    reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation ARPA, loopback not set
  Keepalive not set
  ARP type: ARPA, ARP Timeout 04:00:00
  Last input 00:00:55, output 00:00:04, output hang never
  Last clearing of "show interface" counters never
  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
  Queueing strategy: fifo
  Output queue :0/40 (size/max)
  5 minute input rate 0 bits/sec, 0 packets/sec
  5 minute output rate 0 bits/sec, 0 packets/sec
    17080 packets input, 5844484 bytes, 0 no buffer
    Received 56 broadcasts, 0 runts, 0 giants, 0 throttles
    0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
    0 input packets with dribble condition detected
    22197 packets output, 5455867 bytes, 0 underruns
    0 output errors, 8 collisions, 7 interface resets
    0 babbles, 0 late collision, 19 deferred
    0 lost carrier, 0 no carrier
    0 output buffer failures, 0 output buffers swapped out
Ethernet1 is up, line protocol is up
  Hardware is Lance, address is 0000.0c5c.fe7f (bia 0000.0c5c.fe7f)
  Internet address is 10.1.2.129/25
  MTU 1500 bytes, BW 10000 Kbit, DLY 1000 usec,
    reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation ARPA, loopback not set
  Keepalive not set
  ARP type: ARPA, ARP Timeout 04:00:00
  Last input 00:00:00, output 00:00:00, output hang never
  Last clearing of "show interface" counters never
  Input queue: 1/75/0/0 (size/max/drops/flushes); Total output drops: 0
  Queueing strategy: fifo
  Output queue :0/40 (size/max)
  5 minute input rate 1000 bits/sec, 1 packets/sec
  5 minute output rate 1000 bits/sec, 1 packets/sec
    6749 packets input, 1203057 bytes, 0 no buffer
    Received 1461 broadcasts, 0 runts, 0 giants, 0 throttles
    0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
    0 input packets with dribble condition detected
    6283 packets output, 1110469 bytes, 0 underruns
    0 output errors, 31 collisions, 7 interface resets
    0 babbles, 0 late collision, 2 deferred
    0 lost carrier, 0 no carrier
    0 output buffer failures, 0 output buffers swapped out
Serial0 is up, line protocol is up
  Hardware is HD64570
  Internet address is 10.1.1.121/30
  MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec,
    reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation HDLC, loopback not set
  Keepalive not set
  Last input 00:00:07, output 00:00:02, output hang never
  Last clearing of "show interface" counters never
  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
  Queueing strategy: fifo
  Output queue :0/40 (size/max)
  5 minute input rate 0 bits/sec, 0 packets/sec
  5 minute output rate 0 bits/sec, 0 packets/sec
    14550 packets input, 1452146 bytes, 0 no buffer
    Received 292 broadcasts, 0 runts, 0 giants, 0 throttles
    0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
    12057 packets output, 1205081 bytes, 0 underruns
    0 output errors, 0 collisions, 2 interface resets
    0 output buffer failures, 0 output buffers swapped out
    22 carrier transitions
    DCD=up  DSR=up  DTR=up  RTS=up  CTS=up
Serial1 is up, line protocol is up
  Hardware is HD64570
  Internet address is 10.1.1.117/30
  MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec,
    reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation HDLC, loopback not set
  Keepalive not set
  Last input 00:00:09, output 00:00:02, output hang never
  Last clearing of "show interface" counters never
  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
  Queueing strategy: weighted fair
  Output queue: 0/1000/64/0 (size/max total/threshold/drops)
    Conversations  0/7/256 (active/max active/max total)
    Reserved Conversations 0/0 (allocated/max allocated)
  5 minute input rate 0 bits/sec, 0 packets/sec
  5 minute output rate 0 bits/sec, 0 packets/sec
    13915 packets input, 4241677 bytes, 0 no buffer
    Received 257 broadcasts, 0 runts, 0 giants, 0 throttles
    0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
    13206 packets output, 4970085 bytes, 0 underruns
    0 output errors, 0 collisions, 5 interface resets
    0 output buffer failures, 0 output buffers swapped out
    9 carrier transitions
    DCD=up  DSR=up  DTR=up  RTS=up  CTS=up
Avatar billede coderdk Praktikant
17. februar 2005 - 16:43 #1
Måske du kan bygge videre på dette:

    $text = file_get_contents( 'din_fil.txt' );

    if ( preg_match_all( "/^.*(ethernet|serial0|serial1).*$/mi", $text, $m ) )
    {
        $m = $m[0];
        foreach( $m as $v )
        {
            echo "$v<br>";
        }
    }
    else
    {
        echo "Fandt intet...";
    }
Avatar billede zeion Nybegynder
22. februar 2005 - 10:17 #2
Jeg takker.. :D
smid et svar
Avatar billede zeion Nybegynder
26. juni 2006 - 12:58 #3
Svar
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester