- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Triming arguments in output from ps -f
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 08:08 AM
11-08-2000 08:08 AM
Triming arguments in output from ps -f
Is there a way to eliminate some of the output from ps -f, while leaving others?
Specifically, I would like to eliminate the trailing arguments of a given command.
If this is not possible...
How can I invoke an application requiring arguments, and restrict the arguments from the ps command. I can NOT modify the application to read from an enviroment variable.
Also, the arguments are passed from the command line, thus the <
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 08:12 AM
11-08-2000 08:12 AM
Re: Triming arguments in output from ps -f
Try using GREP
ie
ps -f|grep "what you want"|grep "what you want inside what you want"
See man grep and man egrep
HTH
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 08:28 AM
11-08-2000 08:28 AM
Re: Triming arguments in output from ps -f
To invoke commands with options in a script you can use the getopt command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 08:29 AM
11-08-2000 08:29 AM
Re: Triming arguments in output from ps -f
ps -f|awk '{print $1,$2,$3,$4,$5}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 08:30 AM
11-08-2000 08:30 AM
Re: Triming arguments in output from ps -f
ps -e
ps -u username
will not show the arguments of the processes
It's difficult to cut the arguments from a 'ps -f' with 'awk' or 'cut' because they
have variable length and position. The number of blank characters isn't fixed either.
What are the 'ps -f' fields that you want to keep ?
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 08:34 AM
11-08-2000 08:34 AM
Re: Triming arguments in output from ps -f
I would like to inhibit the output from ps -f. So that other users running a command as
ps -fe | more should not see the arguments passed to my command.
The arguments happen to be a user/password to a secure database.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 08:47 AM
11-08-2000 08:47 AM
Re: Triming arguments in output from ps -f
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 08:49 AM
11-08-2000 08:49 AM
Re: Triming arguments in output from ps -f
alias ps="ps -fe|grep -v username"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 08:51 AM
11-08-2000 08:51 AM
Re: Triming arguments in output from ps -f
What does your application do if you don't provide the arguments.
For example 'svrmgrl' (oracle) can be called with or without the arguments.
example: svrmgrl system/manager
If you don't provide the arguments, the application will prompt for usermane and password. In this case, an input redirection
(file or here document) can be used.
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 08:57 AM
11-08-2000 08:57 AM
Re: Triming arguments in output from ps -f
if you have enough ./././'s you will overflow the number of characters that can be displayed :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 09:00 AM
11-08-2000 09:00 AM
Re: Triming arguments in output from ps -f
if you have enough ./././'s you will overflow the number of characters that can be displayed :-)
eg.
#sh ././././././././././././././././././././././././././././././././test&
ps -ef | grep sh
root 22796 22763 0 11:55:46 pts/0 0:00 sh ././././././././././././././././././././././././././././.
does that solve your problem?
Sorry, submit button was acting up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 09:05 AM
11-08-2000 09:05 AM
Re: Triming arguments in output from ps -f
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 09:35 AM
11-08-2000 09:35 AM
Re: Triming arguments in output from ps -f
You could create a 'ps' wrapper to replace the real 'ps' command. A crude version of this script would look like this:
#!/usr/bin/sh
if (( `id -u` == 0 )) #...root can see all...
then
/usr/bin/ps.realone "$@"
else
/usr/bin/ps.realone "$@"|awk '{print $1,$2,$3,$4,$5,$6,$7,$8}'
fi
The script needs to be embellished to parse (with getopts, for instance) the arguments passed to it making the trimming done by awk fit the output that will be returned. The script, would be named /usr/bin/ps and the real /usr/bin/ps renamed as suggested.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 09:43 AM
11-08-2000 09:43 AM
Re: Triming arguments in output from ps -f
I would prefer to pass it in from the command line, and for security measures inhibit the output from ps -f to OTHER users.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 11:25 AM
11-08-2000 11:25 AM
Re: Triming arguments in output from ps -f
There is still a race condition between starting the process and changing the ps output. A ps run during that interval may see the original arguments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 12:46 PM
11-08-2000 12:46 PM
Re: Triming arguments in output from ps -f
UNIX95= ps -e -o ruser,vsz,pid,args
Note: UNIX95= is correct. It means: set the variable UNIX95 to nothing (which defines it) and by putting it on the same line, the variable remains defined only for the ps command. DON'T SET UNIX95 for everyone or even put it into root...there are several behavior changes in both libraries as well as commands that will take place when this XPG4 variable exists. Better to use it as needed.
So for the original question, here is ps -f (equivalent) without any arguments and then followed by the same with just the command (args = command line, comm = command only):
UNIX95= ps -e -o user,pid,ppid,cpu,stime,tty,time
UNIX95= ps -e -o user,pid,ppid,cpu,stime,tty,time,comm
You can arrange and choose the values inn any order (except args must be last when used).
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 01:59 PM
11-08-2000 01:59 PM
Re: Triming arguments in output from ps -f
Certainly, the UNIX95 variable is a terrific feature, and it will definitely be useful info in the future. But not in this case:)
Again, I would like to run a command in 'some way', so that when OTHERS use the ps -f command THEY should NOT see the args to command.
Hopefuly, this clarifies things.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 02:11 PM
11-08-2000 02:11 PM
Re: Triming arguments in output from ps -f
I'm curious. What do you find "objectionable" to the solution I proposed (above)?
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 02:16 PM
11-08-2000 02:16 PM
Re: Triming arguments in output from ps -f
I'm curious. What do you find "objectionable" to the solution I suggested above?
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 04:11 PM
11-08-2000 04:11 PM
Re: Triming arguments in output from ps -f
I've been following this all day, and something in the 'UNIX95' suggestion hit me the right way. If you add an alias to the .profile files for those you DON'T want to be able to see the arguments supplied, and tell them to just use 'ls' rather than 'ls -r', it would work. I just tried it and here is the alias line from my .profile, the output of 'ls', and the output of 'ls -r' in the attached file.
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 04:13 PM
11-08-2000 04:13 PM
Re: Triming arguments in output from ps -f
And you can tell your users you're trying to help them out!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2000 04:20 PM
11-08-2000 04:20 PM
Re: Triming arguments in output from ps -f
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2000 01:34 AM
11-09-2000 01:34 AM
Re: Triming arguments in output from ps -f
Let's say that your application is in /usr/local/apps/myapp. Then if you start it like //////////////////usr/local/apps/myapp ARG1 ARG2 ... you would only see slashes in the output from ps -ef. (60 slashes in the beginning should be enough)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2000 07:34 AM
11-09-2000 07:34 AM
Re: Triming arguments in output from ps -f
My original problem had noting to do with formatting the output of the ps command. I realize my original question was misleading. I hope that this has been clarified. Your solution deals with formatting the output from the ps command.
Kofi's suggestion does solve the problem as elaborated by Tommy. However, I don't think there is any magic about that:)
By the way, I tried aliasing the command like alias -x run="run user/pass". This did not help; the output from ps -f still displays the user/pass.
For now, I am going with Kofi's solution, unless you can come up with some magic.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2000 07:42 AM
11-09-2000 07:42 AM
Re: Triming arguments in output from ps -f
One more thing, I am not a real fan of "RedfineTheWorld":)
Thanks