Quel tal, quisiera saber si alguien me puede dar una idea en lo siguiente.
Tengo un archivo de texto generado por otro programa el cual tiene muchos campos en cada segmento, de los cuales suelen repetirse valores al azar, lo que quiero es extraer 3 valores de cada segmento sin repetir los resultados extraidos, aqui el contenido de mi archivo datos.txt
Código:
CM> 0x000e4aac ['DHCP Client Thread' id=0x807c8fa0] BcmDhcpClientIf::ProcessPacket: (DHCP ClientIf for IP Stack1) INFO - Parsed the DHCP packet:
DHCP Packet contents:
Type = 2
Hops = 0
Xid = 0x5c76374
Secs = 0
Flags = 0x8000
Bcast Enabled = true
pfDhcpLeaseSettings = 0x805542ec
DHCP Lease Settings:
Is Valid = true
DHCP Message Type = Offer
Hardware Type (htype) = 1
Hardware Length (hlen) = 6
Client IP Address (ciaddr) = 0.0.0.0
Your IP Address (yiaddr) = 10.36.128.65
My offered IP address = 10.36.128.65
TFTP Server IP address (siaddr) = 192.168.4.1
Relay Agent IP address (giaddr) = 10.36.128.1
Client Hardware Address (chaddr) = 00:1c:fb:2f:09:40
TFTP Server Name = (12 of 12 bytes) '192.168.4.1'
Boot Filename = (16 of 16 bytes) 'cm-001cfb2f0940'
DHCP Options = (125 of 125 bytes)
(1) Subnet Mask = 255.255.224.0
(2) UTC Time Offset = -18000
(3) Router IP address = 10.36.128.1
(4) Time Server IP address = 192.168.4.1; 192.168.4.1
(7) Log Server IP address = 192.168.4.1; 192.168.4.1
(51) Lease time = 1382400
(54) DHCP Server IP address = 192.168.4.1
(122) PacketCable =
01 04 c0 a8 04 01 02 04 c0 a8 04 01
(67) Boot File Name = 'cm-001cfb2f0940'
0x000e4aac ['DHCP Client Thread' id=0x807c8fa0] BcmDhcpClientIf::ProcessPacket: (DHCP ClientIf for IP Stack3) INFO - Parsed the DHCP packet:
DHCP Packet contents:
Type = 2
Hops = 0
Xid = 0x5c76374
Secs = 0
Flags = 0x8000
Bcast Enabled = true
pfDhcpLeaseSettings = 0x80552f0c
DHCP Lease Settings:
Is Valid = true
DHCP Message Type = Offer
Hardware Type (htype) = 1
Hardware Length (hlen) = 6
Client IP Address (ciaddr) = 0.0.0.0
Your IP Address (yiaddr) = 10.36.128.65
My offered IP address = 10.36.128.65
TFTP Server IP address (siaddr) = 192.168.4.1
Relay Agent IP address (giaddr) = 10.36.128.1
Client Hardware Address (chaddr) = 00:1c:fb:2f:09:40
TFTP Server Name = (12 of 12 bytes) '192.168.4.1'
Boot Filename = (16 of 16 bytes) 'cm-001cfb2f0940'
DHCP Options = (125 of 125 bytes)
(1) Subnet Mask = 255.255.224.0
(2) UTC Time Offset = -18000
(3) Router IP address = 10.36.128.1
(4) Time Server IP address = 192.168.4.1; 192.168.4.1
(7) Log Server IP address = 192.168.4.1; 192.168.4.1
(51) Lease time = 1382400
(54) DHCP Server IP address = 192.168.4.1
(122) PacketCable =
01 04 c0 a8 04 01 02 04 c0 a8 04 01
(67) Boot File Name = 'cm-001cfb2f0940'
0x001919c8 ['DHCP Client Thread' id=0x807c8fa0] BcmDhcpClientIf::ProcessPacket: (DHCP ClientIf for IP Stack3) INFO - Parsed the DHCP packet:
DHCP Packet contents:
Type = 2
Hops = 0
Xid = 0x5c76374
Secs = 0
Flags = 0x8000
Bcast Enabled = true
pfDhcpLeaseSettings = 0x80552f0c
DHCP Lease Settings:
Is Valid = true
DHCP Message Type = Offer
Hardware Type (htype) = 1
Hardware Length (hlen) = 6
Client IP Address (ciaddr) = 0.0.0.0
Your IP Address (yiaddr) = 10.36.138.20
My offered IP address = 10.36.138.20
TFTP Server IP address (siaddr) = 192.168.4.1
Relay Agent IP address (giaddr) = 10.36.128.1
Client Hardware Address (chaddr) = 00:1c:fb:32:e1:be
TFTP Server Name = (12 of 12 bytes) '192.168.4.1'
Boot Filename = (16 of 16 bytes) 'cm-001cfb32e1be'
DHCP Options = (125 of 125 bytes)
(1) Subnet Mask = 255.255.224.0
(2) UTC Time Offset = -18000
(3) Router IP address = 10.36.128.1
(4) Time Server IP address = 192.168.4.1; 192.168.4.1
(7) Log Server IP address = 192.168.4.1; 192.168.4.1
(51) Lease time = 1382400
(54) DHCP Server IP address = 192.168.4.1
(122) PacketCable =
01 04 c0 a8 04 01 02 04 c0 a8 04 01
(67) Boot File Name = 'cm-001cfb32e1be'
De todo este texto solo quiero extraer lo siguiente:
Código:
My offered IP address Client Hardware Address (chaddr) (67) Boot File Name
10.36.128.65 00:1c:fb:2f:09:40 cm-001cfb2f0940
10.36.138.20 00:1c:fb:32:e1:be cm-001cfb32e1be
Dicho Resultado me gustaria mostrarlo en pantalla y a su vez se genere otro archivo de texto con los resultados.
se que tengo que empezar con:
Código PHP:
if ($file = fopen( "/ruta/datos.txt", "r")) {
// Aqui código para recuperar datos NO SE QUE HACER
fclose($file);
}
Agradeceria mucho su ayuda.