How to avoid truncating in ps output ?


 
Thread Tools Search this Thread
Operating Systems Solaris How to avoid truncating in ps output ?
# 1  
Old 04-27-2018
How to avoid truncating in ps output ?

Hello,
This is Solaris 10 (x86)
Code:
bash-3.2# cat /etc/release
                        Solaris 10 5/09 s10x_u7wos_08 X86
           Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                             Assembled 30 March 2009
bash-3.2#

I am not able to figure out, how to avoid trucating in ps output. I want full path, but is is cutting lines in the last. Even if I redirect output to a file, it is same.
I tried multiple ways, but still same
Code:
bash-3.2# /usr/ucb/ps -wwwwwaux | grep syslog-ng | egrep -v grep
root     13862  1.6  0.1 8420 4388 ?        S   Apr 11 330:37 /usr/local/sbin/syslog-ng --cfgfile /logs/c720/syslog-ng.conf --pidfile /var/ru
root     21187  0.1  0.1 7756 3728 ?        S   Apr 13 100:51 /usr/local/sbin/syslog-ng --cfgfile /logs/neteng/syslog-ng.conf --pidfile /var/
root      4804  0.0  0.0 6404 1432 ?        S   Apr 25  0:00 /usr/local/sbin/syslog-ng --cfgfile /etc/syslog-ng.conf --pidfile /var/run/sysl
root      4805  0.0  0.0 6404 1432 ?        S   Apr 25  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/test/syslog-ng.conf --pidfile /var/ru
root      4806  0.0  0.1 6800 2812 ?        S   Apr 25  0:00 /usr/local/sbin/syslog-ng --cfgfile /etc/syslog-ng.conf --pidfile /var/run/sysl
root      4807  0.0  0.1 6828 2796 ?        S   Apr 25  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/test/syslog-ng.conf --pidfile /var/ru
root     10595  0.0  0.0 6404 1432 ?        S   Sep 24  0:00 /usr/local/sbin/syslog-ng --cfgfile /etc/syslog-ng.conf --pidfile /var/run/sysl
root     10596  0.0  0.1 8376 4380 ?        S   Sep 24  0:08 /usr/local/sbin/syslog-ng --cfgfile /etc/syslog-ng.conf --pidfile /var/run/sysl
root     13844  0.0  0.0 6404 1432 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/nss/syslog-ng.conf --pidfile /var/run
root     13845  0.0  0.1 8212 4184 ?        S   Apr 11  0:02 /usr/local/sbin/syslog-ng --cfgfile /logs/nss/syslog-ng.conf --pidfile /var/run
root     13858  0.0  0.0 6404 1432 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/lbs/syslog-ng.conf --pidfile /var/run
root     13859  0.0  0.1 8228 4200 ?        S   Apr 11  0:02 /usr/local/sbin/syslog-ng --cfgfile /logs/lbs/syslog-ng.conf --pidfile /var/run
root     13861  0.0  0.0 6404 1432 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/c720/syslog-ng.conf --pidfile /var/ru
root     13894  0.0  0.0 6404 1432 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/sbsd/syslog-ng.conf --pidfile /var/ru
root     13896  0.0  0.1 8428 4380 ?        S   Apr 11  1:15 /usr/local/sbin/syslog-ng --cfgfile /logs/sbsd/syslog-ng.conf --pidfile /var/ru
root     13897  0.0  0.0 6404 1432 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/v720/syslog-ng.conf --pidfile /var/ru
root     13898  0.0  0.1 8332 4304 ?        S   Apr 11  1:14 /usr/local/sbin/syslog-ng --cfgfile /logs/v720/syslog-ng.conf --pidfile /var/ru
root     13906  0.0  0.0 6404 1432 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/wks/syslog-ng.conf --pidfile /var/run
root     13907  0.0  0.1 8228 4200 ?        S   Apr 11  0:02 /usr/local/sbin/syslog-ng --cfgfile /logs/wks/syslog-ng.conf --pidfile /var/run
root     13936  0.0  0.0 6404 1432 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /etc/syslog-ng.conf --pidfile /var/run/sysl
root     13937  0.0  0.1 6864 2876 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /etc/syslog-ng.conf --pidfile /var/run/sysl
root     18153  0.0  0.0 6404 1432 ?        S   Jul 18  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/ng720/syslog-ng.conf --pidfile /var/r
root     18154  0.0  0.23867634604 ?        S   Jul 18  9:46 /usr/local/sbin/syslog-ng --cfgfile /logs/ng720/syslog-ng.conf --pidfile /var/r
root     21186  0.0  0.0 6404 1432 ?        S   Apr 13  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/neteng/syslog-ng.conf --pidfile /var/
bash-3.2# which ps
/usr/bin/ps
bash-3.2# /usr/bin/ps -wwwwwaux | grep syslog-ng | egrep -v grep
/usr/bin/ps: illegal option -- w
/usr/bin/ps: illegal option -- w
/usr/bin/ps: illegal option -- w
/usr/bin/ps: illegal option -- w
/usr/bin/ps: illegal option -- w
usage: ps [ -aAdeflcjLPyZ ] [ -o format ] [ -t termlist ]
        [ -u userlist ] [ -U userlist ] [ -G grouplist ]
        [ -p proclist ] [ -g pgrplist ] [ -s sidlist ] [ -z zonelist ]
  'format' is one or more of:
        user ruser group rgroup uid ruid gid rgid pid ppid pgid sid taskid ctid
        pri opri pcpu pmem vsz rss osz nice class time etime stime zone zoneid
        f s c lwp nlwp psr tty addr wchan fname comm args projid project pset
bash-3.2#

Please suggest the correct way
# 2  
Old 04-27-2018
Not too familiar with Solaris, I would have had proposed to make use of (man ps):
Quote:
-o format The -o option allows the output format to be specified under user control. . . . The field widths are selected by the system to be at least as wide as the header text (default or overridden value).
BUT I'm afraid you're out of luck in that special case:

Quote:
args The command with all its arguments as a string. . . The Solaris implementation limits the string to 80 bytes;
which is exactly the length of your output fields...
# 3  
Old 04-27-2018
In Solaris the public args, as shown with /usr/bin/ps, are truncated after 80 characters.
The full args are stored in the process environment.
/usr/ucb/ps wwwaux tries to access the full args of each process. It should succeed if you own the process or if you are root.
This is a bit slowish though.

The recommended way is to use /usr/bin/ps and then pargs to only dig out the full args if needed.
Code:
/usr/bin/ps -eo pid= -o comm= | awk '$2~/syslog-ng/ { print $1 }' | xargs -l pargs

or
Code:
/usr/bin/ps -eo pid= -o args= | awk '$2~/syslog[-]ng/ { print $1 }' | xargs -l pargs

In the latter the own arguments must be excluded from args, most elegant by using a [ ] character set in the regular expression.
These 2 Users Gave Thanks to MadeInGermany For This Post:
# 4  
Old 04-27-2018
Seems like, this also doesn't work. Am I running it correctly ?
Code:
bash-3.2# /usr/ucb/ps wwwaux | grep syslog-ng | egrep -v grep | head -2
root     13862  0.3  0.1 8428 4528 ?        S   Apr 11 337:37 /usr/local/sbin/syslog-ng --cfgfile /logs/c911/syslog-ng.conf --pidfile /var/ru
root     21187  0.1  0.1 7764 3868 ?        S   Apr 13 101:39 /usr/local/sbin/syslog-ng --cfgfile /logs/neteng/syslog-ng.conf --pidfile /var/
bash-3.2#
bash-3.2# /usr/bin/ps -eo pid= -o comm= | awk '$2~/syslog-ng/ { print $1 }' | xargs -l pargs | head
13897:  /usr/local/sbin/syslog-ng --cfgfile /logs/v911/syslog-ng.conf --pidfile /var/ru
argv[0]: supervising syslog-ng
argv[1]: <NULL>
argv[2]: <NULL>
argv[3]: <NULL>
argv[4]: <NULL>
13859:  /usr/local/sbin/syslog-ng --cfgfile /logs/lbs/syslog-ng.conf --pidfile /var/run
argv[0]: /usr/local/sbin/syslog-ng
argv[1]: <NULL>
argv[2]: <NULL>
xargs: Child killed with signal 13
bash-3.2#
bash-3.2# /usr/bin/ps -eo pid= -o args= | awk '$2~/syslog[-]ng/ { print $1 }' | xargs -l pargs | head
13897:  /usr/local/sbin/syslog-ng --cfgfile /logs/v911/syslog-ng.conf --pidfile /var/ru
argv[0]: supervising syslog-ng
argv[1]: <NULL>
argv[2]: <NULL>
argv[3]: <NULL>
argv[4]: <NULL>
13859:  /usr/local/sbin/syslog-ng --cfgfile /logs/lbs/syslog-ng.conf --pidfile /var/run
argv[0]: /usr/local/sbin/syslog-ng
argv[1]: <NULL>
argv[2]: <NULL>
xargs: Child killed with signal 13
bash-3.2#

# 5  
Old 04-27-2018
It seems syslog-ng overwrote/cleared its arguments array. You are out of luck.

You might use a dtrace script to intercept the arguments when the commands are exec'd and log them to a file.
These 2 Users Gave Thanks to jlliagre For This Post:
# 6  
Old 04-27-2018
Yes, I will go alternate way.
Thanks you all. I will mark this thread as solved.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

awk truncating first field output?

Hello, I'm writing an Awk script to take a command line argument (student's name) and output their relevant student#, name, and marks. For some reason, awk arbitrarily removes the first digit from the student number and doesn't show me the proper output. Here is my code: #! /usr/bin/awk -f... (6 Replies)
Discussion started by: trashmouth12
6 Replies

2. Shell Programming and Scripting

Avoid single line output from function

I am new to shell scripting and wished to get few things clarified. While calling functions within shell script, output comes out as single line irrespective of the no of echos or newlines I tried within function + the echo -e used to invoke function ( as instructed online) : #!/bin/sh inc() {... (1 Reply)
Discussion started by: RMath
1 Replies

3. Shell Programming and Scripting

nawk is truncating output

Legends, I have 2 files f1 and f2. when i use nawk to compare the difference(subtraction) from 4th column of the file, it truncates the output. can you please help to resolve this. subtraction is (4th col of f1 - 4th col of f2). but it gives only below lines out of 116. I want to print all... (7 Replies)
Discussion started by: sdosanjh
7 Replies

4. Shell Programming and Scripting

how to avoid cron job output to send to the junk email folder?

Hi i created a cron job which invoke a shell script and output some content via email. Some times these output are sent to the junk email folder. i want these mails to be sent to inbox with some specific font. what i have to do? (4 Replies)
Discussion started by: vidhyaS
4 Replies

5. Shell Programming and Scripting

How to avoid the truncating of multiple spaces into a single space while reading a line from a file?

consider the small piece of code while read line do echo $line done < example content of example file sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the output is like sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the... (4 Replies)
Discussion started by: Kesavan
4 Replies

6. UNIX for Dummies Questions & Answers

how to avoid time command output

Hi, I have 2 queries 1 .when I run some unix command, I am getting the output of "time" at std output (screen) for eg zegrep <pattern> *.v.gz I almost found the reason but not sure, if the no of files matching *.v.gz is more then I am getting the time command output at the... (5 Replies)
Discussion started by: selvaka
5 Replies

7. UNIX for Dummies Questions & Answers

Truncating the last character

Hi all , I am creating the file which holds the create query to run in the sql prompt: so when i am creating: create table XXX( SD Varchar2(10), DF Varchar2(10),) I am getting one comma at the last ,before i am inserting the closing bracket i need to delete that? kindly provide me the... (1 Reply)
Discussion started by: ithirak17
1 Replies

8. Shell Programming and Scripting

Truncating a variable

I have a variable that is a full path name and I just want the file name with out the extension. I have figured out how to do this using some temp files but I would really like to avoid that if possible. I know I can do echo ${TMPNAME%.*} to drop the extension is there a similar way to drop... (3 Replies)
Discussion started by: whdr02
3 Replies

9. UNIX for Dummies Questions & Answers

`ps` command truncating text

I have some processes that show a long file path as part of the process name and the process name gets truncated off. Does anyone know how to get the full output from the `ps`command so that I can see the whole process name? (9 Replies)
Discussion started by: keelba
9 Replies

10. Shell Programming and Scripting

Can I avoid the standard output from kill command

I am sending a kill comand to kill a process inside a SH script but I don`t want the user to notice it so I donīt want the message "1222 killed" to appear. I`ve tried to redirect the standard output to /dev/null 2>&1 and also tried to use "nohup" but none of them was succesfull. Can anyone... (1 Reply)
Discussion started by: pguinal
1 Replies
Login or Register to Ask a Question

Featured Tech Videos