I want to attach to a running process using ‘ddd’, what I manually do is:
# ps -ax | grep PROCESS_NAME
Then I get a list and the pid, then I type:
# ddd PROCESS_NAME THE_PID
Is there is a way to type just one command directly?
Remark: When I type ps -ax | grep PROCESS_NAME, grep will match both the process and grep command line itself.
There is an easy way to get rid of the grep process:
(as long as the process you’re trying to find doesn’t include the string
" grep ").So something like this should work in a script (again, assuming there’s only one copy running):
If you call your script
dddproc, you can call it with:Although I’d add some sanity checks such as detecting if there’s zero or more than one process returned from
psand ensuring the user supplies an argument.