Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Dear Friends,
I want to Ping LDAP Server(say 10.10.10.112) from a Script, store the data in a file and then grep last 2-3lines from that file to know LDAP Response.Last 2-3 Lines are normally:-
"4 packets transmitted, 4 packets received, 0% packet loss
round-trip (ms) min/avg/max = 0/0/0
"
So it gives a fair idea of LDAP Response.
Here is a small Script and its output:-
----------
bash-2.03# cat pingserver.sh
#!/bin/ksh
ping -s 10.10.10.112 &
sleep 5
pkill -f ping
bash-2.03# sh pingserver.sh
PING 10.10.10.112: 56 data bytes
64 bytes from mllndata (10.10.10.112): icmp_seq=0. time=0. ms
64 bytes from mllndata (10.10.10.112): icmp_seq=1. time=0. ms
64 bytes from mllndata (10.10.10.112): icmp_seq=2. time=0. ms
64 bytes from mllndata (10.10.10.112): icmp_seq=3. time=0. ms
64 bytes from mllndata (10.10.10.112): icmp_seq=4. time=0. ms
64 bytes from mllndata (10.10.10.112): icmp_seq=5. time=0. ms
24534 Terminated
bash-2.03#
-----------
Here I am having 3 issues:-
1)I used '&' , still Ping output is coming onto screen(Not Desirable, I have tried Redirection[>] also).
2)When I stop Ping with Cntl+C, it gives %packet loss line and max/avg/min Line. But here as I abruptly killed using pkill,those lines were not printed.
3)How to Run Ping in Background and also catch output in a file simultaneously?I will be grateful if anyone can Produce a Solution to this Problem.
Thanx and Regards

Ping then pipe to is what you want.
Also use ping options for times, not sleep.
"Best Practices", Event viewer, host file, perfmon, antivirus, anti-spyware, Live CD's, backups, are in my top 10

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |