Results 1 to 7 of 7
I am having trouble redirecting I/O for ping when a host does not exist. For instance,
Code:
ping http://www.123abc.com &> out
ping: unknown host http://www.123abc.com
is the trouble I'm having. ...
- 07-05-2011 #1Just Joined!
- Join Date
- Dec 2006
- Posts
- 41
Ping I/O will not redirect
I am having trouble redirecting I/O for ping when a host does not exist. For instance,
is the trouble I'm having. I have tried redirecting everything I know, but the command will not run silently nor print anything to the output file. (No, this isn't a problem with > vs >>). I'm trying to ping a list of sites, so I really need an output for every site regardless if it exists or not.Code:ping http://www.123abc.com &> out ping: unknown host http://www.123abc.com
Thanks!
- 07-05-2011 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
The output is going to stderr, which you are not redirecting. Try this:
Code:ping http://www.123abc.com &> out 2>>out
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 07-05-2011 #3Just Joined!
- Join Date
- Dec 2006
- Posts
- 41
I swear I did that before and it didn't work. Now it does. (Facepalm)
- 07-05-2011 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Or as my friend Homer says - Doh!
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 07-05-2011 #5Just Joined!
- Join Date
- Dec 2006
- Posts
- 41
Nope, still an issue. I'm using some nasty regex to strip out the data I want. This doesn't work:
Code:ping -c 1 -W 5 http://www.abc123.com | head -n 2 | sed 's/) 56(84) bytes of data.\|PING \|64 bytes from \|:.*//g' | sed 's/([0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\})\|(//g' &>> pingOut 2>> pingOut
- 07-05-2011 #6Just Joined!
- Join Date
- Dec 2006
- Posts
- 41
Anyone? Thanks . . .
- 07-06-2011 #7Linux Guru
- Join Date
- May 2011
- Posts
- 1,842
is this bash or csh? i'm not familiar with csh redirecting...anyway, try this bash version:
Code:ping -c 1 -W 5 http://www.abc123.com 2>&1 | head -n 2 | sed 's/) 56(84) bytes of data.\|PING \|64 bytes from \|:.*//g' | sed 's/([0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\})\|(//g' >> pingOut 2>&1


Reply With Quote