ps -eo pid,ppid,uid,user,args
If i use above command on any of my sol boxes,i see that fifth column (args or COMMAND) is truncated.
Is there a way of getting full details in this column ,like we have in AIX?
Regards
Abhi
ps -eo pid,ppid,uid,user,args
If i use above command on any of my sol boxes,i see that fifth column (args or COMMAND) is truncated.
Is there a way of getting full details in this column ,like we have in AIX?
Regards
Abhi
The usual workaround is:
/usr/ucb/ps -alxwww
If you haven't /usr/ucb/ps installed (eg. OpenSolaris), you might also use
pargs -a <pid>
to see a process full argument list.
Thanks !!
/usr/ucb/ps -alxwww
this command does not show 'user' column....does it?
Any way of getting that column as well?
I am comparing above command's o/p with
ps -eo pid,ppid,uid,user,args
Regards
Abhi
It does show UID which is closely related.
Yes, use the 'u' option but you loose the PPID column ... :-\
/usr/ucb/ps -aluwww
hmm...thanks !!
so no hope for me to get all necessary columns....??
I need all those columns with 'args' expanded completely.
Regards
Abhi
Either a small shell script that would process ps output to convert uid to usernames or modifying the ps source code to suit your needs ...
I would really appreciate if someone can guide me on script to get all these columns !!!
Regards
Abhi
This might work:
/usr/ucb/ps -alxww | nawk '
$2 != "UID" { printf("%s ",$1); system("getent passwd "$2" | sed s/:.*$// | tr -d \\\\n"); $1=""; $2=""; print $0 }
$2 == "UID" { $2="USER" ; print }
'
Thanks for that !!
Can we still get 'UID' column some how ?
I am not good enough to understand what you wrote.Maybe i am missing something here.
I need all five columns.
Appreciating again !!
Regards
Abhi
/usr/ucb/ps -alxww | nawk '
$2 != "UID" { printf("%s %s ",$1,$2); system("getent passwd "$2" | sed s/:.*$// | tr -d \\\\n"); $1=""; $2=""; print $0 }
$2 == "UID" { $2="UID USER"; print }
'
thanks !!
why am i struggling to assign it to a variable ?
bash-3.00$ A=`/usr/ucb/ps -alxww | nawk '$2 != "UID" { printf("%s %s ",$1,$2);system("getent passwd "$2"| sed s/:.*$// | tr -d \\\\n");$1=""; $2=""; print $0 }$2 == "UID" { $2="UID USER"; print }'|awk -F' ' '{ if($4 == "14217") print $5}'`
bash-3.00$ echo "$A"
If run as is,it return $5 value ...but not in a variable...why so?
just an example
bash-3.00$ /usr/ucb/ps -alxww | nawk '$2 != "UID" { printf("%s %s ",$1,$2);system("getent passwd "$2"| sed s/:.*$// | tr -d \\\\n");$1=""; $2=""; print $0 }$2 == "UID" { $2="UID USER"; print }'|awk -F' ' '{ if($4 == "25148") print $5}'
25147
bash-3.00$ A=`/usr/ucb/ps -alxww | nawk '$2 != "UID" { printf("%s %s ",$1,$2);system("getent passwd "$2"| sed s/:.*$// | tr -d \\\\n");$1=""; $2=""; print $0 }$2 == "UID" { $2="UID USER"; print }'|awk -F' ' '{ if($4 == "25148") print $5}'`
bash-3.00$ echo $A
bash-3.00$
Regards
Abhi
Why using such a complicated way if you only need to display a process parent process id ?
ps -o ppid -p 25148 | grep -v PPID
well...it looks simple but unfortunately it is not....
value 25148 is not ready for me...my engine scans a host ,runs the command and obtains a PID .After that it gets other columns based on this PID..in short,its dynamic.
Another reason of using '/usr/ucb/ps' is why i opened this thread.'COMMAND' gets truncated if i use '/usr/bin/ps'.
I would really be greatful if i get some help on these 2 issues.
1.As mentioned earlier,assigning the o/p to a variable.
/usr/ucb/ps -alxww | nawk '$2 != "UID" { printf("%s %s ",$1,$2);system("getent passwd "$2"| sed s/:.*$// | tr -d \\\\n");$1=""; $2=""; print $0 }$2 == "UID" { $2="UID USER"; print }'|awk -F' ' '{ if($4 == "@@Host Processes.PID@@") {$1=$2=$3=$4=$5=$6=$7=$8=$9=$10=$11=$12=$13=$14="";substr("^ ","");print} }'
Since COMMAND column is usually 15th, i was trying to write above code to get everything in COMMAND column for a PID.
e.g
0 25 smmsp 726 1 0 59 20 8152 1768 300015bd6c6 S ? 0:16 /usr/lib/sendmail -Ac -q15m
For PID '726' i am trying to get hold of '/usr/lib/sendmail -Ac -q15m'.i.e all of this string in a variable.
Kindly guide me where its wrong.
Regards
Abhi
okay...
i got the variable assignment part but the other one is still in question.
bash-3.00$ A=$(/usr/ucb/ps -alxww | nawk '$2 != "UID" { printf("%s %s ",$1,$2);system("getent passwd "$2"| sed s/:.*$// | tr -d \\\\n");$1=""; $2=""; print $0 }$2 == "UID" { $2="UID USER"; print }'|awk '{ if($4 == "25788"){substr("^ ","");print}}')
bash-3.00$ echo $A
0 0 root 25788 1 0 29 30353272231552 00038470 S ? 336:39 /global/site/vendor/WAS/WebSphere6/AppServer/java/bin/java -XX:MaxPermSize=256m
how do i get hold of 'command' column value for a given PID?
for e.g... refer above..
I need to get "/global/site/vendor/WAS/WebSphere6/AppServer/java/bin/java -XX:MaxPermSize=256m" in a variable ?
I can't use awk '{print $13}' as this is just an example... this COMMAND column value can come at any column number...meaning its dynamic...so i need something which will give anything present in that column to a variable....
Appreciating help !!
Regards
Abhi
---------- Post updated at 11:05 PM ---------- Previous update was at 09:01 PM ----------
well...i think i found it !!
bash-3.00$ A=$(/usr/ucb/ps -alxww | nawk '$2 != "UID" { printf("%s %s ",$1,$2);system("getent passwd "$2"| sed s/:.*$// | tr -d \\\\n");$1=""; $2=""; print $0 }$2 == "UID" { $2="UID USER"; print }'|awk '{ if($4 == "25788"){substr("^ ","");print}}')
bash-3.00$ echo $A
0 0 root 25788 1 0 29 30353272231552 00038470 S ? 337:00 /global/site/vendor/WAS/WebSphere6/AppServer/java/bin/java -XX:MaxPermSize=256m
bash-3.00$ echo $A|nawk '{print substr($0, index($0,":")+3, length($0))}'
/global/site/vendor/WAS/WebSphere6/AppServer/java/bin/java -XX:MaxPermSize=256m
Thanks for responding !!
Regards
Abhi