CYGWIN_NT-5.1 1.7.0(0.214/5/3) ps (cygwin) 1.11 - how do I display the arguments to the processes?

Haojun Bao baohaojun@gmail.com
Thu Nov 19 04:33:00 GMT 2009


Chris January <chris@atomice.net> writes:
>
> Install the procps package and then use the procps command.
>

You can also try WMIC which comes with Windows, on XP in my case.

If you need for e.g., PID/PPID/CMDLINE, especially if you need see
Windows native processes and if procps can't do that (I don't know if it
can or not), then you can use this script:

#!/bin/perl

## here, "</dev/null" needed because wmic.exe get confused if STDIN is a pipe 

$Processes=`wmic.exe path win32_process get CommandLine,ProcessId,ParentProcessId </dev/null`;
@Processes = split /\r*\n/, $Processes;

$Processes[0] =~ m/^(CommandLine.*)(ParentProcessId.*)(ProcessId.*)$/ or #the order of pid/ppid seems to be random with wmic?
    die "can't match the first line";

$\="\n";
printf "%9s%9s  %s\n", PID, PPID, COMMAND;
foreach (@Processes[1..$#Processes]) {
    m/^(.*?)\s*([0-9]+)\s*([0-9]+)\s*$/ or die "can't match $_";
    printf "%9d%9d  %s\n", $3, $2, $1;
}


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list