man pages in Windows

At work, I’ve found myself SSHing into this Windows web server (thanks to Cygwin) often enough that I start to just think of it as another Linux server. And while Cygwin allows you to run Windows commands from a bash prompt, Windows commands don’t come with man pages (just /?). Microsoft has an A-Z List of Windows commands online, but sometimes I’d just prefer to stick to the command prompt. Conveniently, the documentation renders well in a text-based browser. To make these show up as man pages, you just need to have a text-based web browser installed, and have the html files named as the commands in a particular “chapter” of the manual. I picked chapter 9, as that’s not generally assigned.

apt-cyg install wget links # You probably don't have apt-cyg installed,
# so grab that or just use Cygwin's setup.exe instead
# to ensure wget and links are installed
ln -s /usr/bin/links /usr/bin/lynx # Man expects lynx for html pages
mkdir -p /usr/local/share/man/html9
cd /usr/local/share/man/html9
wget -O- 'http://technet.microsoft.com/en-us/library/cc772390(WS.10).aspx' |\
grep -Po 'ctl00_MTCS_main_ctl.+href="\K([^"]+)(:.+>)([^>]+)(?=)' index.html |\
sed -r 's/^([^"]+).+>([^>]+)$/\1 \2/' | \
while read url name
do name=`echo ${name// /-} | tr '[:upper:]' '[:lower:]'`
wget -O "$name.9.html" "$url"
done

That will get you man pages for all the commands in that A-Z list. For man pages on subcommands like “net computer”, type “man net-computer”. If you look at that list you’ll notice “net computer” but no “net use” or any of the other usual commands — of course, many of the net commands are well-documented through “net help”. If you really want to be unixy, you can dump those net help pages out to the manual too. Since they’re not formatted, you’ll want to put them in the cat9 directory instead of the html9 directory, and drop the .html extensions.

mkdir -p /usr/local/share/man/cat9
cd /usr/local/share/man/cat9
for cmd in `net 2>&1 | grep '|' | sed 's/^NET//;s/[^A-Z]/ /g' | tr '[:upper:]' '[:lower:]'` ; do net help $cmd > net-$cmd.9 ; done

I don’t know of any comprehensive list of commands besides the A-Z list and the net commands list. But to create individual man pages, you can do something like:

wget -O sqlcmd.9.html 'http://msdn.microsoft.com/en-us/library/ms162773(d=printer).aspx'

This will give you a man page for sqlcmd, the command-line client for SQL Server. If you wanted to grab all the man pages for the net subcommands (instead of using the results from “net help”), do

for x in accounts computer continue file group help helpmsg localgroup name pause print sendshare session start statistics stop time use user view ; do wget -O net-$x.9.html "http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_$x.mspx" ; done
wget -O net-config.9.html 'http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_config_server.mspx'

If you’re looking for a little more Ubuntu/Debianism in Windows, try Richard’s apt-get update; apt-get dist-upgrade for Wndows. Got any more urls for man pages? Please post a comment and share!

This entry was posted in Code. Bookmark the permalink.

One Response to man pages in Windows

  1. Pingback: Windows man pages? · Code: Rich

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>