I want to write a script in KSH that takes the output of one command and redisplays it. Something like:
while true
do
read inpt
date +"%I:%M:%S %p <-> $inpt"
done
and then some how get the output of the ping command to redirect to the input of this script.
does that make sense?
era
2
ping -c 1 otherhost | while read inpt; do
date +"%I:%M:%S %p <-> $input"
done
The -c 1 restricts this to one ping packet; if you want it to keep going, then certainly, just take out the "-c 1".
typo: inpt ---> input
ping -c 1 otherhost | while read input; do
date +"%I:%M:%S %p <-> $input"
done
Also note that "%r" can be used instead of "%I:%M:%S %p" as in
ping -c 1 otherhost | while read input; do
date +%r" <-> $input"
done