| | Stumble It! | Add to Mixx! | | diigo it | | Slashdot |

Tuesday, October 28, 2008

Fixing Ping in Cygwin

I apologize for the heavy geek that follows:

Every networker knows ping, for many of us it's a daily (hourly!) used tool. One of the things I do is host an SSH server on my home computer for a variety of purposes, one of which is to have a third-party testing platform so that I can verify connectivity from multiple paths. Unfortunately I goofed up somewhere in the installation process and whenever I tried to run ping from within cygwin, I was faced with a string of ping: recvfrom: Invalid argument scrolling up my screen at break-neck speed.

After a bit of digging around, I found that this was because the permissions of my user account (I don't surf with my admin account) prevented me from accessing the resources needed to send ping packets.

Luckily, there's a quick work-around. Cygwin is able to access and execute all the same commands that are normally available through the Windows command prompt to include ping. Here's how you can solve this problem:
at the $ prompt type $SYSTEMROOT/system32/ping google.com and you will see pings sent out.
A cooler way to achieve this is to use an alias in your .bashrc file. To do this you need to
  1. Open Windows Explorer and navigate your way to your cygwin\home directory (usually C:\cygwin\home\).
  2. Open the folder for the user account you log in with.
  3. Open the file named .bashrc in your favorite text editor (mine is Notepad++).
  4. Add the following line to the end of the file:
    alias p='$SYSTEMROOT/system32/ping'
  5. Then restart your cygwin window and instead of typing out the whole $SYSTEMROOT/blah/blah, just type p google.com!

2 comments:

alexandern said...

Thank you!.

Make sure you check in the edited form as it could happen that you dont see the EDIT or NEW options ..


Thanks again!

Jerome said...

Awesome! Thanks. I had coded a workaround which used 'wget' instead of 'ping', but your solution is perfect.

Jerry Fehribach