How to view the process with arguments in windows using any cygwin utilities

if I use "ps -efW", it lists Windows processes, but not with command line arguments.

I came across 3 links where it says to use "pstree", "/ proc / PID / cmdline", "procps".

http://cygwin.com/ml/cygwin/2007-04/msg00813.html

http://cygwin.com/ml/cygwin/2007-04/msg00817.html

http://cygwin.com/ml/cygwin/2007-04/msg00821.html

but I did not find, except procps in the 32-bit cygwin package.

even after installing procps, I don’t know how to use. read the manual page. but did not receive any clue.

can anyone help?

eg,

using the wmic command, I can see the complete process with arguments.

C:\Users\test1>wmic process get ProcessID, Commandline /format:csv |grep cmd OSWIN7VC10-32B1,"C:\Windows\system32\cmd.exe" ,2904 OSWIN7VC10-32B1,C:\Windows\system32\cmd.exe /cc:\ostore74\src\osci\scripts\buil d_test\nt\batch_conf\winnt_vc100_weekly.bat >C:\Users\test1\AppData\Local\Tem p\s1io.4 2>C:\Users\test1\AppData\Local\Temp\s1io.5,3968 OSWIN7VC10-32B1,C:\Windows\system32\cmd.exe /c C:\apache-ant-1.7.1\bin\ant.bat - Djboss.home=C:\ostore74\tmp\javaee\jboss-4.2.3.GA -emacs -k -f C:\ostore74\src\j mtl\build.xml overnight >> \\ostorenas\odi\ostore_platform_logs\ostore\7.4 .0\test1\winnt_vc100\2013-10-18-1720\unit_retail_jmtl.log 2>&1,1864 OSWIN7VC10-32B1,"C:\Windows\system32\cmd.exe" ,604 OSWIN7VC10-32B1,grep cmd,2064 

but using the cygwin ps command.

 C:\Users\test1>ps -efW |grep cmd 0 2904 0 ? Oct 17 C:\Windows\System32\cmd.exe 0 3968 0 ? Oct 18 C:\Windows\System32\cmd.exe 0 1864 0 ? Oct 18 C:\Windows\System32\cmd.exe 0 3200 0 ? 08:39:43 C:\Windows\System32\cmd.exe 
+6
source share
2 answers

If you only need arguments for cygwin processes, you can use

 procps -wwFAH 

or

 pstree -a 

(pstree is part of the psmisc package).

If you need arguments for Windows processes, you can also use wmic (it works in the cygwin shell). Alternatively, you can try to schedule the process.c of the win7util package to include the full command line.

+6
source

Foreword: Good ... So it was very annoying. There seemed to be no viable way to programmatically capture this information in Cygwin. Each time I started the solution, it took more than 20 minutes, rejecting the path / solution and restarting it. Using WMI, Wmic, even pulling from the registry, became ridiculous. Nothing provided a reliable exit, and most of the time even WMI did not list the CMD line. Always finished creating dll / exe parser.

Then today I did some work with the DLL, independent of Cygwin, and typed "listdlls". At first I thought it was just some kind of minimized function or alias, most likely Nirsoft RegDLLView . But he quickly realized his probably Sysinternal listdlls.exe , which is the command line!

Decision:

  • search and store pid for search query name
  • save results "listdlls.exe"
  • loop through the pids array \
  • pid \ search process name
  • print the corresponding command line for the process name according to the results of listdlls

For an example example (dependencies: listdlls.exe, grep, awk, ps "procps"):

 __getexecmd () { [ -z " $@ " ] && return 1 local term=" $@ " hash listdlls || return 1 local dlls="$(listdlls)" for i in $(ps -Wa | awk '/'"$term"'/ {print $1}'); do echo "$dlls" | grep -A1 "$i" | awk '/Command\ line\:/{gsub(/Command\ line\:\ /,"");print $0}' done return 0 } 

I really think this is what you were. Let me know. Greetings

+1
source

Source: https://habr.com/ru/post/956559/


All Articles