While working at the DOS command line in Windows, I had the idea of using the DOS TASKLIST command along with xtopdf, my PDF generation toolkit, to generate a list of currently running Windows tasks to a PDF file, along with some other info, such as whether a task is a service or a console process, the process id, the memory usage, etc. The TASKLIST command shows all that information, by default.
I also sorted the output in ascending order by the Mem Usage field, by passing it through the DOS SORT command. (I could have sorted it by any other field such as the Image Name or the PID, of course.) I starred out some of the fields in the output.
Here are the steps to generate a Windows task list as a PDF, using xtopdf:
( I use $ as the prompt, even in DOS :)
1: Run TASKLIST and redirect its output to a text file.
$ tasklist > tasklist.out
2: Sort the file into another file.
$ sort /+65 tasklist.out > tasklist.srt
(Sort the output of TASKLIST by the character position of the Mem Usage field.)
3: Go edit tasklist to put the header lines back at the top :)
[ They get dislodged by the sort. ]
[ This is not Unix, so you can't easily do the fast, fluid command-line data munging that you can on Unix, unless you use something like Cygwin or UWin.
UWin was developed by David Korn, creator of the Korn Shell, for Windows. You can get UWin from the AT&T site here (after doing a convoluted license agreement dance, last time I checked). But IMO, the dance is not too long, and is worth it, to get a suite of Unix tools that work well on Windows, and UWin is also smaller & lighter than Cygwin, though not so comprehensive.
Be sure to read the section "Korn shell and Microsoft" at the David Korn link above :-) ]
4: Pipe the sorted task list to StdinToPDF, to generate the PDF output.
$ type tasklist.srt | python StdinToPDF.py tasklist.pdf
We just pipe the output of TASKLIST to StdinToPDF.py (an xtopdf app), which can be used at the end of any arbitrary command pipeline that generates text (on Unix / Windows / Linux / Mac OS X), to convert that text to PDF.
A screenshot of the PDF output I got (viewed in Foxit PDF Reader), is shown at the top of this post.
- Vasudev Ram - Online Python training and programming Signup to hear about new products and services I create. Posts about Python Posts about xtopdf My ActiveState recipes