I'm working on a program that can query running X apps, save all the commands of running apps and them reopen them latter.
I encounter an issue. wmctctl can query the pid of Onlyoffice, for example the pid is 123. Then run ps -ef -q 123, I see that the CMD is ./DesktopEditors which should be a invalid command, because ./one_command only can work in special folder include file one_command.
I can get a complete command by running ps -ef -q $(pgrep -P 123).
Is there a straight way to get the complete command of Onlyoffice just via wmctl and ps?
If there is a better way to get all commands of X apps, please let me know. Thanks.
I suggest using
ps -h -e -o pid,argscommand piped with agrepThis should provide full command path with it arguments and options.
For example find all running java programs with their arguments (might be extensive):
In your case I suggest a small awk script, that looks for the pid given as 3rd input field in current line:
Sample output
update
Transforming current directory
./to to full path. Assuming./represent the current working directory. Add the following pipe.Find the script or program
DesktopEditorsin your computer, usingfind / -name "DesktopEditors".But I believe this is useless if you are trying to reverse engineer a web based application that requires some kind of a browser emulator.