Hi,
Maybe you should add the full path of the 'ping' utility to the ping calls.
Secondly, you should call ping specifying the total number of packets to be sent, to prevent the job from not ending.
And thirdly, it would be best for you to encapsulate all this work on a single shell file...