Viewing Category: Cygwin  [clear category selection]

Console Apps for Windows

Many years ago, I used a terminal application on Windows (I believe it was Windows NT 4.0) called SecureCRT. That worked very well to connect to all my FreeBSD/Linux/Sun boxes over SSH. I've used PuTTY before too, and it's a fine application. However, neither of these provide a good command line environment (shell) on the local machine; I still used C:\WINNT\system32\cmd.exe. I had forgotten until just a moment ago (when @stevenerat asked about it, and @carehart replied), but there is a property called "Quick Edit Mode" that will change the behavior of selecting text in the console window. That's good, but there are two way better fixes that can be applied to Windows for people that love the command line.

First, do yourself a favor and install Cygwin if you haven't already.

Console2 - This open source project provides a very clean wrapper for the standard Windows shell, or the Cygwin version of Bash. It support tabbed windows with a mixture of different configuration settings. Its default for selecting and copying text from the console is left-shift and left-mouse click and drag; pressing enter copies to the clipboard. It's very lightweight and only requires dropping a single directory to the system. There is no installer to run. The current version is only a few months old. Download the binary distribution from SourceForge: Console2

Ponderosa - This is also an open source project, however it doesn't seem that any work has been done since 2006. Still, it functions well and has lots of configuration options. The default copy/paste keystrokes are ALT + C/V, which will feel more familiar to Mac users. It's based on .NET 2.0, which may or may not be appealing you. It supports plugins, although I haven't looked to see what is available. The English version of their website is en.ponderosa.org.

Listening Programs in Windows

While trying to get the line debugger in ColdFusion Builder to work with an installation of ColdFusion 9, I wanted to verify which processes were listening for TCP connections on my Windows XP workstation. I started by using the netstat utility in C:\WINDOWS\system32\ to show the IP and port of each connected endpoint, and the local process identifier. This is useful, but somewhat cumbersome to translate into recognizable application names. Here's a sample of its output:

Proto Local Address Foreign Address State PID TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 3772 TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 1988 TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4 TCP 127.0.0.1:1117 127.0.0.1:4331 ESTABLISHED 3980 TCP 127.0.0.1:1130 0.0.0.0:0 LISTENING 1264 TCP 127.0.0.1:1208 127.0.0.1:20345 ESTABLISHED 640 TCP 127.0.0.1:1217 127.0.0.1:20345 ESTABLISHED 3000 TCP 127.0.0.1:4331 0.0.0.0:0 LISTENING 504

Using the process utility from Cygwin, it's possible to list all of the running processes. It has some quirks when showing Windows information, but it works. Here's a sample of that information:

PID TTY STIME COMMAND 4 ? Apr 22 *** unknown *** 1412 ? 09:03:14 \SystemRoot\System32\smss.exe 1528 ? 09:03:17 \??\C:\WINDOWS\system32\csrss.exe 1552 ? 09:03:22 \??\C:\WINDOWS\system32\winlogon.exe 1600 ? 09:03:24 C:\WINDOWS\system32\services.exe 1612 ? 09:03:24 C:\WINDOWS\system32\lsass.exe 1812 ? 09:03:25 C:\WINDOWS\system32\nvsvc32.exe 1152 ? 09:03:28 C:\Program Files\Symantec\Symantec Endpoint Protection\Smc.exe 1908 ? 09:03:32 C:\Program Files\Common Files\Symantec Shared\ccSvcHst.exe 752 ? 09:03:33 C:\WINDOWS\system32\spoolsv.exe 1860 ? 09:03:42 C:\WINDOWS\system32\svchost.exe 1320 ? 09:03:43 C:\Program Files\Google\Google Desktop Search\GoogleDesktop.exe

I needed to merge the two sources of information together. I started in the shell by chaining a few tools together, but it became awkward and inefficient. I switched to Perl, and hacked together a script that produces output like this:

Connections: 25 3772: 0.0.0.0:80 0.0.0.0:0 C:\Program Files\Apache Software Foundation\Apache2.2\bin\httpd.exe 1988: 0.0.0.0:135 0.0.0.0:0 C:\WINDOWS\system32\svchost.exe 4: 0.0.0.0:445 0.0.0.0:0 Windows System Process 3748: 10.0.1.169:1402 74.125.19.147:80 C:\Program Files\Google\Google Desktop Search\GoogleDesktop.exe 3464: 10.0.1.169:1520 204.2.160.49:80 c:\Program Files\Microsoft IntelliType Pro\dpupdchk.exe 3316: 10.0.1.169:1538 10.0.1.2:1025 C:\Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE 652: 10.0.1.169:1828 205.188.1.113:5190 C:\Program Files\Pidgin\pidgin.exe

Don't overlook how beautifully the IP and port are aligned. :) The source is available in my Subversion repository as listening.pl.