Título: Script Bash lento.... Publicado por: soyloqbuskas en 23 Marzo 2012, 18:00 pm ¡Buenas a todos!
He hecho est script en bash pero es demasiado lento.....hace muchos accesos a ficheros.... ¿me podrian ayudar a optimizarlo? Código
La parte que deberia cambiar son las asignaciones a las variables ip1, ip2, port1, port2 y seqnum Esas variables deberia llenarlas sin tener que hacer una lectura para cada una de ellas o algo asi.... ¿Alguna idea de como hacerlo? Gracias, un saludo! Título: Re: Script Bash lento.... Publicado por: ox1d0 en 30 Marzo 2012, 03:48 am La parte que tarda por lo menos a mi ..
es el tcpdump y es normal es lo que tarda en capturar el paquete Es bueno para debugear sh -x ejemplo: sh -x ip.sh + tcpdump -A -i eth0 -nvXSs 0 -c1 tcp + grep cksum + grep Flags + head -n 1 + cut -c5-130 tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes 1 packet captured 1 packet received by filter 0 packets dropped by kernel ++ cut '-d ' -f1 ficheroAux ++ cut -d. -f1-4 + ip1=10.40.64.183 ++ cut '-d ' -f1 ficheroAux ++ cut -d. -f5 + port1=37979 ++ cut -d: -f1 ficheroAux ++ cut '-d ' -f2- ++ cut -d. -f1-4 ++ cut -c3-15 + ip2=74.125.47.125 ++ cut -d: -f1 ficheroAux ++ cut -d. -f9 + port2=443 ++ cut -dq -f2 ficheroAux ++ cut -c2-11 ++ cut -d, -f1 + let seqnum=0.40.64.18 ip.sh: line 9: let: seqnum=0.40.64.18: syntax error: invalid arithmetic operator (error token is ".40.64.18") + let seqnumInc=+1 + hping3 -a 74.125.47.125 10.40.64.183 -s 443 -p 37979 -M 1234567890 -L 1 -S -A -c 1 HPING 10.40.64.183 (eth0 10.40.64.183): SA set, 40 headers + 0 data bytes len=52 ip=10.40.64.183 ttl=64 DF id=3589 sport=37979 flags=A seq=0 win=477 rtt=0.2 ms --- 10.40.64.183 hping statistic --- 1 packets tramitted, 1 packets received, 0% packet loss round-trip min/avg/max = 0.2/0.2/0.2 ms + let seqnumInc2=1+1 + hping3 -a 74.125.47.125 10.40.64.183 -s 443 -p 37979 -M 1234567891 -L 2 -A -c 1 HPING 10.40.64.183 (eth0 10.40.64.183): A set, 40 headers + 0 data bytes len=52 ip=10.40.64.183 ttl=64 DF id=3590 sport=37979 flags=A seq=0 win=477 rtt=0.2 ms --- 10.40.64.183 hping statistic --- 1 packets tramitted, 1 packets received, 0% packet loss round-trip min/avg/max = 0.2/0.2/0.2 ms + hping3 -a 74.125.47.125 10.40.64.183 -s 443 -p 37979 -M 1234567891 -L 2 -A -P -c 1 -d 500 -E miFichero.html HPING 10.40.64.183 (eth0 10.40.64.183): AP set, 40 headers + 500 data bytes [main] memlockall(): Success Warning: can't disable memory paging! [datafiller] open(): No such file or directory len=52 ip=10.40.64.183 ttl=64 DF id=3591 sport=37979 flags=A seq=0 win=477 rtt=0.2 ms Probe con la opsion -s pero el ratraso es por el filtro en si .. Aunque en realidad no tarda demasiado .. PD esto probando tu Man in thel midle .. que posteaste .. quiza los filtros del cut funcionen mas rapido con perl o awk quizas .. |