Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command to display the entire process without truncating?

Status
Not open for further replies.

srjordan

Technical User
Jun 14, 2004
8
CA
Hello everyone,

I'm trying to display an entire process without truncating the end of it in AIX (via ps). Does anyone know a way of doing this? This seems like a very basic task and I've found a few people who've asked the question and a few answers but nobody seems to be able to do it in AIX.

Any help is greatly appreciated.
 
I think it still truncates at some point (I don't have any with long enough command lines to see it, though), but this gives a longer view of the command than most:

ps -ef -o pid,args

You can substitute any of the X/Open Standards flags (see man ps) for the "-ef". The man page also lists the fields that can be used with the -o format option.

For a single process, use:

ps -o pid,args -p <pid>



Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Rod, thanks for the reply. I still get a truncated result but at least I understand the -o parameter a little more. For example, if I run

ps -ef -o ruser,pid,args|grep 32070

I get back (check out the end, it's truncated)

was_env 32070 /usr/WebSphere/AppServer5/java/bin/java -Xbootclasspath/p:/usr/WebSphere/AppServer5/java/jre/lib/ext/ibmorb.jar -Dcom.ibm.CORBA.ConfigURL=file:/usr/WebSphere/AppServer5/properties/sas.client.props -Dcom.ibm.SOAP.ConfigURL=file:/usr/WebSphere/AppServer5/properties/soap.client.props -Dcom.ibm.CORBA.RasManager=com.ibm.websphere.ras.WsOrbRasManager -Dwas.install.root=/usr/WebSphere/AppServer5 -Dws.ext.dirs=/usr/WebSphere/AppServer5/java/lib:/usr/WebSphere/AppServer5/classes:/usr/WebSphere/AppServer5/lib:/usr/WebSphere/AppServer5/lib/ext:/usr/WebSphere/AppServer5/web/help:/usr/WebSphere/AppServer5/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime:/usr/mqm/java/lib:/usr/opt/wemps/lib -Djava.security.auth.login.config=/usr/WebSphere/AppServer5/properties/wsjaas_client.conf -Dcom.ibm.CORBA.BootstrapHost= -Dcom.ibm.CORBA.BootstrapPort= -Djava.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory -classpath /usr/WebSphere/AppServer5/properties:/usr/WebSphere/AppServer5/lib/bootstrap.jar:/usr/WebSphere/AppServer5/lib/j2ee.jar:/usr/WebSphere/AppServer5/lib/lmproxy.jar:/usr/WebSphere/AppServer5/lib/urlprotocols.jar:/usr/WebSphere/AppServer5/lib/urlprotocols.jar com.ibm.ws.bootstrap.WSLauncher com.ibm.websphere.client.applicationclient.launchClient /usr/bsiapps/env/ear/Env.ear -CCBootstrapPort=2817 -CCclasspath=/usr/WebSphere/AppServer5/installedApps/pot2Network/Env.ear/EnvBase.jar:/usr/WebSphere/AppServer5/installedApps/pot2Network/Env.ear/EnvUserMgmt.jar:/usr/WebSphere/AppServer5/installedApps/pot2Network/Env.ear/AppCapabilities.jar:/usr/WebSphere/AppServer5/installedApps/pot2Network/Env.ear/EnvAppFramework.jar:/usr/WebSphere/AppServer5/installedApps/pot2Network/Env.ear/Log4j.jar:/usr/WebSphere/AppServer5/installedApps/pot2Network/Lto.ear/LtoWeb.war/WEB-INF/classes:/usr/WebSphere/AppServer5/installedApps/pot2Network/Dist.ear/DistEJB.jar:/usr/WebSphere/AppServer5/installedApps/pot2Network/Ppr.ear/PprEJB.jar:/usr/WebSphere/AppServer5/installedApps/pot2Network/Ppr.ear/CpsEJB.jar:/usr/

I know it's not the grep command that is truncating it because if I run without the grep and look for the pid, it is still truncated. So it would appear the "args" parameter of the -o switch is really, really long. Is there any way of specifying say the last 100 chars of the "args" paramter or something like that? I'm open to any suggestions. As you may have guessed, I'm running WebSphere on AIX.

aau

Thank-you for replying however if I run "ps auxw", I get even less information on the pid. For example, if I use the pid from above and run "ps auxw|grep 32070" I get

was_env 32070 0.1 3.0 51004 34736 pts/2 A 12:12:34 7:13 /usr/WebSphere/AppServer5/java/bin/java -Xbootclasspath/p:/usr/WebSp

However, if I add a w to it and run "ps auxww" I get quite a bit more but it is still truncated as follows:

was_env 32070 0.1 3.0 51004 34736 pts/2 A 12:12:34 7:13 /usr/WebSphere/AppServer5/java/bin/java -Xbootclasspath/p:/usr/WebSphere/AppServer5/java/jre/lib/ext/ibmorb.jar -Dcom.ibm.CORBA.ConfigURL=file:/usr/WebSphere/AppServer5/properties/sas.client.props -Dcom.ibm.SOAP.ConfigURL=file:/usr/WebSphere/AppServer5/properties/soap.client.props -Dcom.ibm.CORBA.RasManager=com.ibm.websphere.ras.WsOrbRasManager -Dwas.install.root=/usr/WebSphere/AppServer5 -Dws.ext.dirs=/usr/WebSphere/AppServer5/java/lib:/usr/WebSphere/AppServer5/classes:/usr/WebSphere/AppServer5/lib:/usr/WebSphere/AppServer5/lib/ext:/usr/WebSphere/AppServer5/web/help:/usr/WebSphere/AppServer5/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime:/usr/mqm/java/lib:/usr/opt/wemps/lib -Djava.security.auth.login.config=/usr/WebSphere/AppServer5/properties/wsjaas_client.conf -Dcom.ibm.CORBA.BootstrapHost= -Dcom.ibm.CORBA.BootstrapPort= -Djava.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory -classpath /usr/WebSphere/AppServer5/properties:/usr/WebSphere/AppServer5/lib/bootstrap.jar:/usr/WebSphere/AppServer5/lib/j2ee.jar:/usr/WebSphere/AppServer5/lib/lmproxy.jar:/usr/WebSphere/AppServer5/lib/urlprotocols.jar:/usr/WebSphere/AppServer5/lib/urlprotocols.jar com.ibm.ws.bootstrap.WSLauncher com.ibm.websphere.client.applicationclient.launchClient /usr/bsiapps/env/ear/Env.ear -CCBootstrapPort=2817 -CCclasspath=/usr/WebSphere/AppServer5/installedApps/pot2Network/Env.ear/EnvBase.jar:/usr/WebSphere/AppServer5/installedApps/pot2Network/Env.ear/EnvUserMgmt.jar:/usr/WebSphere/AppServer5/installedApps/pot2Network/Env.ear/AppCapabilities.jar:/usr/WebSphere/AppServer5/installedApps/pot2Network/Env.ear/EnvAppFramework.jar:/usr/WebSphere/AppServer5/installedApps/pot2Network/Env.ear/Log4j.jar:/usr/WebSphere/AppServer5/installedApps/pot2Network/Lto.ear/LtoWeb.war/WEB-INF/classes:/usr/WebSphere/AppServer5/installedApps/pot2Network/Dist.ear/DistEJB.jar:/usr/WebSphere/AppServer5/installedApps/pot2Network/Ppr.ear/PprEJB.jar:/usr/WebSphere/AppServer5/inst

Any ideas?
 
Install the Proc::processTable module for perl. The "cmndline" field should show you every last character. I tested it with an awk command line of 8K, spanning 473 lines (don't ask).

The perldoc page for Proc::processTable gives some sample uses that should give a good enough starting place for you, if you're even mildly comfortable with perl.



Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Thanks Rod,

I'm a little new to perl. However, I've been working on it since you posted your reply. We were running perl 5.6.0 and it would appear that I required perl 5.8 to compile the Proc::processTable module.

So I downloaded and installed perl 5.8.0-2 and then I was able to compile the Proc::processTable module.

I'm not sure how to use Proc::processTable. Can I see how you used it with your awk sample? That would make my life a little easier.
 
srjordan,

The awk script I refered to was just something I could run that I knew would provide a ridiculously long command line. It's an exceedingly "clever" script I wrote early my sysadmin career and I can't be bothered to refactor, mainly because it works like a charm.

Here's a perl script that will accept a single pid on the command line and spit out it's full command line:

Code:
#!/usr/bin/perl -w

use strict;

use Proc::ProcessTable;

my $mypid = shift;

my $t = new Proc::ProcessTable;

foreach my $p ( @{$t->table} ){

   if ( $p->pid == $mypid )
      {
      print $mypid, ":  ",  $p->{cmndline}, "\n";
      }
   }

I'm using version 0.35 of Proc::processTable with perl version 5.005. Hopefully the interface hasn't changed.

HTH,

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
please accept it: the max output of 'ps' is (historically)
fixed to 80 chars (terminal -tty- size)
the /usr/ucb/ps aux will print a lot infos about
the env, the ps itself is still truncate to 80 chars.
i understand the need of longer output ... but 80 is the MAX
so use short path, mk links, instead of /aa/bb/cc/dd/ff/exec abc
use ./exec abc, and ./exec is a link to ../../../../../exec

:) guggach
 
bjverzal,

Nice tip! It still truncates, but it looks like it's at 2048 characters, which is longer than any of the other ps answers so far.

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Woo Hoo good news!

But I'll save it till the end.

First of all, bjverzal, thank-you for posting however the process still gets truncated.

guggach, thank-you as well for your input and you are correct. ps does have a limit but I'm not sure if it is 80 chars since my post above displays a lot more than 80 chars. Having said that, If I run the ps -efl|fold (that bjverzal suggested), it wraps at 80 chars and displays a lot more information but I still run into the truncated process issue. I haven't bothered to count every single character to see what the limit is exactly. It wraps at 80 because the COLUMNS environment parameter is set to 80 by default. (Also, I think you are running on Solaris if you use /usr/ucb/ps (?), on AIX it is in /usr/bin/ps and I've seen different behavior between different flavors of *nix with regard to ps)

Also, I agree that having the short path in the command whould help me out alot and if I were able to manipulate the command, it would proabably show the whole thing but I don't have access to the command or most of it's parameters so it's not possible to change the command and use shorter paths.

So after all that and three days of testing, I finally got it to work soooooooo now on to the good news........ :)

Rob was on a different track. Instead of using the built in "ps" command that comes with AIX, he suggested using a perl function that accesses the internal process table directly. (Thank-you for the sample script, it still works like a charm with perl 5.8 and Proc::processTable-0.39).

So here's my final analysis:

PROBLEM: While running WebSphere 5 on AIX 5.2, I noticed that while doing a ps -ef|grep <pid>, some pids were truncated and I couldn't see the entire command. Unfortunately, some important information is at the end of the process and I need that information.

SOLUTION: Use the Proc::processTable perl module and do not use the built-in ps command with AIX. ps has a limit which causes the display of the command to be truncated.

HOW TO GET THERE:

1. Ensure you have a c compiler (with cc_r and xlc). The compile process for Proc::processTable requires both of them.

2. I was running perl 5.6.0 and wasn't having a lot of luck compiling the Proc::processTable module. I had to download perl 5.8.0-2 and it worked after I changed a few of the links in /usr/bin (like perl, perldoc, perlcc, and perlbug to perl's default install directory: /opt/freeware/bin/). So I suggest downloading perl 5.8 but other people may get other versions working. In the end, you need perl

3. Download and compile the Proc::processTable module. If you read the README, it will tell you everything you need to do to compile it.

4. Take Rod's code above and put it into a file. I called mine test.pl and make sure it is executable.

5. Now to compare, run ps -ef|grep <pid that has a really long command line>. For example, if I run "ps -ef|grep 42550, I get (notice it's truncated)

webadmin 42550 22226 0 06:03:57 - 0:37 /usr/WebSphere/AppServer5/java/bin/java -Xbootclasspath/p:/usr/WebSphere/AppServer5/java/jre/lib/ext/ibmorb.jar:/usr/bsiapps/coonuans/support/jsseExtended.jar -Dcom.ibm.CORBA.ConfigURL=file:/usr/WebSphere/AppServer5/properties/sas.client.props -Dcom.ibm.SOAP.ConfigURL=file:/usr/WebSphere/AppServer5/properties/soap.client.props -Dcom.ibm.CORBA.RasManager=com.ibm.websphere.ras.WsOrbRasManager -Dwas.install.root=/usr/WebSphere/AppServer5 -Dws.ext.dirs=/usr/WebSphere/AppServer5/java/lib:/usr/WebSphere/AppServer5/classes:/usr/WebSphere/AppServer5/lib:/usr/WebSphere/AppServer5/lib/ext:/usr/WebSphere/AppServer5/web/help:/usr/WebSphere/AppServer5/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime:/usr/mqm/java/lib:/usr/opt/wemps/lib -Djava.security.auth.login.config=/usr/WebSphere/AppServer5/properties/wsjaas_client.conf -Dcom.ibm.CORBA.BootstrapHost= -Dcom.ibm.CORBA.BootstrapPort= -Djava.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory -classpath /usr/WebSphere/AppServer5/properties:/usr/WebSphere/AppServer5/lib/bootstrap.jar:/usr/WebSphere/AppServer5/lib/j2ee.jar:/usr/WebSphere/AppServer5/lib/lmproxy.jar:/usr/WebSphere/AppServer5/lib/urlprotocols.jar:/usr/WebSphere/AppServer5/lib/urlprotocols.jar com.ibm.ws.bootstrap.WSLauncher com.ibm.websphere.client.applicationclient.launchClient /usr/bsiapps/coonuans/ear/CooNuans.ear -CCDjavax.net.ssl.trustStore=/usr/bsiapps/coonuans/resources/bsicerts -CCDjavax.net.ssl.keyStorePassword=bsi4admin -CCBootstrapPort=2816 -CCclasspath=/usr/bsiapps/coonuans/resources:/usr/bsiapps/coo/resources:/usr/mqm/java/lib/com.ibm.mq.jar:/usr/mqm/java/lib/com.ibm.mqjms.jar:/usr/mqm/java/lib/connector.jar:/usr/mqm/java/lib/jms.jar:usr/mqm/java/lib/jndi.jar:/usr/mqm/java/lib/jta.jar:/usr/mqm/java:/usr/WebSphere/AppServer5/lib/websphere.jar:/usr/WebSphere/AppServer5/lib/ujc.jar:/usr/mqm/java/lib/com.ibm.mq.jar:/usr/mqm/java/lib/com.ibm.mqjms.jar:/usr/mqm/java/lib/connector.jar:/usr/mqm/java/lib/jms.jar:usr/mqm/java/lib/jndi

6. Now run ./test.pl <pid that has a really long cmd line>. For example, I ran ./test.pl 42550 and here's what I got: (notice it isn't truncated)

42550: /usr/WebSphere/AppServer5/java/bin/java -Xbootclasspath/p:/usr/WebSphere/AppServer5/java/jre/lib/ext/ibmorb.jar:/usr/bsiapps/coonuans/support/jsseExtended.jar -Dcom.ibm.CORBA.ConfigURL=file:/usr/WebSphere/AppServer5/properties/sas.client.props -Dcom.ibm.SOAP.ConfigURL=file:/usr/WebSphere/AppServer5/properties/soap.client.props -Dcom.ibm.CORBA.RasManager=com.ibm.websphere.ras.WsOrbRasManager -Dwas.install.root=/usr/WebSphere/AppServer5 -Dws.ext.dirs=/usr/WebSphere/AppServer5/java/lib:/usr/WebSphere/AppServer5/classes:/usr/WebSphere/AppServer5/lib:/usr/WebSphere/AppServer5/lib/ext:/usr/WebSphere/AppServer5/web/help:/usr/WebSphere/AppServer5/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime:/usr/mqm/java/lib:/usr/opt/wemps/lib -Djava.security.auth.login.config=/usr/WebSphere/AppServer5/properties/wsjaas_client.conf -Dcom.ibm.CORBA.BootstrapHost= -Dcom.ibm.CORBA.BootstrapPort= -Djava.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory -classpath /usr/WebSphere/AppServer5/properties:/usr/WebSphere/AppServer5/lib/bootstrap.jar:/usr/WebSphere/AppServer5/lib/j2ee.jar:/usr/WebSphere/AppServer5/lib/lmproxy.jar:/usr/WebSphere/AppServer5/lib/urlprotocols.jar:/usr/WebSphere/AppServer5/lib/urlprotocols.jar com.ibm.ws.bootstrap.WSLauncher com.ibm.websphere.client.applicationclient.launchClient /usr/bsiapps/coonuans/ear/CooNuans.ear -CCDjavax.net.ssl.trustStore=/usr/bsiapps/coonuans/resources/bsicerts -CCDjavax.net.ssl.keyStorePassword=bsi4admin -CCBootstrapPort=2816 -CCclasspath=/usr/bsiapps/coonuans/resources:/usr/bsiapps/coo/resources:/usr/mqm/java/lib/com.ibm.mq.jar:/usr/mqm/java/lib/com.ibm.mqjms.jar:/usr/mqm/java/lib/connector.jar:/usr/mqm/java/lib/jms.jar:usr/mqm/java/lib/jndi.jar:/usr/mqm/java/lib/jta.jar:/usr/mqm/java:/usr/WebSphere/AppServer5/lib/websphere.jar:/usr/WebSphere/AppServer5/lib/ujc.jar:/usr/mqm/java/lib/com.ibm.mq.jar:/usr/mqm/java/lib/com.ibm.mqjms.jar:/usr/mqm/java/lib/connector.jar:/usr/mqm/java/lib/jms.jar:usr/mqm/java/lib/jndi.jar:/usr/mqm/java/lib/jta.jar:/usr/mqm/java:/usr/WebSphere/AppServer5/lib/websphere.jar:/usr/WebSphere/AppServer5/lib/ujc.jar:/home/dbclient/sqllib/java/db2java.zip:/home/dbclient/sqllib/java/db2jcc.jar:/home/dbclient/sqllib/function:/home/dbclient/sqllib/java/db2jcc_license_cu.jar:. -CCjar=CooNuansServiceAppClient.jar

So in conclusion, it is possible, just a lot of work. I still have a few more hurdles to jump in order to get the username in the output, sorting of pids, displaying of more than one pid, etc, but I think I can handle it from here. Thank-you everyone for your input.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top