long format of ps command in Solaris
I believe you are making it more complex than it needs to be. No need for awk
or ancient version of ps
command.
Try this:
for x in `ps -ed -o pid=`; do echo -n "$x " ; pargs -l $x; done
Or when pretty printed:
for x in `ps -ed -o pid=`; do
echo -n "$x "
pargs -l $x 2>/dev/null # don't want to see err msg for procs that no longer exist
done
This will produce an output with PID and all the cmd args on one line no matter how long. Then you can grep your way through that output if you like.
Remember that pargs
command needs to examine the process and you may not be allowed to do that for all processes .. unless you are root or have equivalent privs.
Related videos on Youtube
Tingrammer
GNU/Linux fan,Want to learn most programming languages. Shell scripting is interest. Interesting languages are , C/C++/Java etc. Perl/lamp/bash scripting/ksh scripting/. Want to learn Python/Lisp/Ruby on rails.
Updated on September 18, 2022Comments
-
Tingrammer over 1 year
Jobs with a long command-line is not printing in Solaris:
bash-3.2$ /usr/ucb/ps auxwww | grep ftf | awk '{print $NF}' | head -5 /proj/cmp01/app/btws/cfg/btw /proj/cmp01/app/btws/cfg/btw /proj/cmp01/app/btws/cfg/btw /proj/cmp01/app/btws/cfg/btw /proj/cmp01/app/btws/cfg/btw bash-3.2$ /usr/ucb/ps -alxww | grep -v "alxww" | grep ftf | grep -v grep|head -5 0 39548 737 693 0 50 20 5112 3952 603110c3e70 S ? 249:55 /usr/bin/bash /proj/cmp01/app/ftf/bin/ftf.sh -y -c /proj/cmp01/app/btws/cfg/btw 0 39548 906 871 0 50 20 4568 3488 6034bfbf348 S ? 245:12 /usr/bin/bash /proj/cmp01/app/ftf/bin/ftf.sh -y -c /proj/cmp01/app/btws/cfg/btw 0 39548 2512 2480 0 50 20 4552 3544 603d5120df8 S ? 134:04 /usr/bin/bash /proj/cmp01/app/ftf/bin/ftf.sh -y -c /proj/cmp01/app/btws/cfg/btw 0 39548 2523 2496 0 50 20 4728 3688 602fcee1d28 S ? 135:43 /usr/bin/bash /proj/cmp01/app/ftf/bin/ftf.sh -y -c /proj/cmp01/app/btws/cfg/btw 0 39548 2557 2535 0 50 20 4472 3480 603df1e0838 S ? 133:48 /usr/bin/bash /proj/cmp01/app/ftf/bin/ftf.sh -y -c /proj/cmp01/app/btws/cfg/btw
It is chopping off part of the configuraton file.
I also cannot use
pargs
:bash-3.2$ for i in `/usr/ucb/ps -alxww | grep -v "alxww" | grep ftf | grep -v gr ep| awk '{print $3}'|head -3`; do pargs $i; done pargs: cannot examine 737: permission denied pargs: cannot examine 2512: permission denied pargs: cannot examine 2523: permission denied bash-3.2$
I checked this question, but I couldn't get the complete arguments:
-
Mikel almost 10 yearsWhat do you think the full arguments look like?
-
Mikel almost 10 yearsIs
ps
printing thepid
as the second or third column? Surely you don't have five processes, all with the pid39548
? -
Tingrammer almost 10 yearsfull arguments look like,
/usr/bin/bash /proj/cmp01/app/ftf/bin/ftf.sh -y -c /proj/cmp01/app/btws/cfg/btws_fnhkdr.cfg /usr/bin/bash /proj/cmp01/app/ftf/bin/ftf.sh -y -c /proj/cmp01/app/btws/cfg/btws_bilvim_e2e.cfg /usr/bin/bash /proj/cmp01/app/ftf/bin/ftf.sh -y -c /proj/cmp01/app/btws/cfg/btws_giwsch_e2e.cfg /usr/bin/bash /proj/cmp01/app/ftf/bin/ftf.sh -y -c /proj/cmp01/app/btws/cfg/btws_bilspi_e2e.cfg /usr/bin/bash /proj/cmp01/app/ftf/bin/ftf.sh -y -c /proj/cmp01/app/btws/cfg/btws_cpbtdr.cfg
-
Tingrammer almost 10 yearsIn the above comment, starting command is
/usr/bin/bash
& there are 5 records. -
Tingrammer almost 10 yearsSorry
ps
is printing pid in 3rd column, updating the question -
Tingrammer almost 10 yearsFound the correct solution. When i run
/usr/ucb/ps auxwww | grep ftf
command in elevated user, it gave me complete ans.dcmh228z:dcmp01 $/usr/ucb/ps auxwww | grep ftf | head -2 dcmp01 807 0.1 0.0 4392 3520 ? S 18:14:31 1:24 /usr/bin/bash /proj/cmp01/app/ftf/bin/ftf.sh -y -c /proj/cmp01/app/btws/cfg/btws_wirwtx.cfg dcmp01 13075 0.0 0.0 4192 3320 ? S 19:54:01 0:00 /usr/bin/bash /proj/cmp01/app/ftf/bin/ftf.sh -y -c /proj/cmp01/app/btws/cfg/btws_wlbai.cfg
-
-
Tingrammer almost 10 yearseven after using above command i m still getting the same error as above ` pargs: cannot examine 20570: no such process or core file`
-
Tingrammer almost 10 yearsThis worked .
Promt: $for i in /usr/ucb/ps -alxww | grep -v "alxww" | grep ftf | grep -v grep | awk '{print $3}'; do pargs $i; done 737: /usr/bin/bash /proj/cmp01/app/ftf/bin/ftf.sh -y -c /proj/cmp01/app/btws/cfg/btw argv[0]: /usr/bin/bash argv[1]: /proj/cmp01/app/ftf/bin/ftf.sh argv[2]: -y argv[3]: -c argv[4]: /proj/cmp01/app/btws/cfg/btws_wlsap.cfg
-
Tingrammer almost 10 yearsSorry couldnt format it properly.
argv[4]
shows complete configuration file -
peterh almost 10 years@Tingrammer. Processes come and go. My script collects the list of PIDs first and then loops these to perform an
pargs
on each of them, one by one. It may happen that a process has ended in the meantime. That's why you get that error message. If you really cannot live with seeing such message then I've updated my answer so that it now doesn't display such errors.