On Mon, 15 Sep 2008 21:29:13 +1200, Chris Hellyar <[EMAIL PROTECTED]> wrote: > For the scripting nut-cases on the list. :-) > > I want to log ping times to an IP into a file using a simple script.... > > It works, but I want my output on a single > > What I've got at the moment: > > #!/bin/bash > ping -c1 $1 >/tmp/pingouttxt > PingRet=$? > if [ "$PingRet" = "0" ]; then > echo -n " OK " > date > echo -n " " > cat /tmp/pingouttxt | grep time= | cut -d "=" -f 4 > else > echo -n " !! DOWN !! " > date > fi > > Which gives me: (For a good ping) > > [EMAIL PROTECTED]:~$ ./testping bob.home > OK Mon Sep 15 21:26:29 NZST 2008 > 0.188 ms > [EMAIL PROTECTED]:~$ > > and (For down) > > [EMAIL PROTECTED]:~$ ./testping broke.home > !! DOWN !! Mon Sep 15 21:26:53 NZST 2008 > [EMAIL PROTECTED]:~$ > > > Either I need to strip the newline off the cat and stick the ping time > before the date, or I need to get it off the newline... > > Anyway, google got me a bunch of samples where people wanted to strip > newlines out of files, but nothing really useful for this one.. > > (And yes, i could do it in something other than bash, that's no the > point, and you know it!) > > Cheers, Me.
printf "%s", "OK $(date) $PingGrepCutResult" Done on a windows box using cygwyn so I hope it will work on a Linux box. Cheers Ross Drummond
