- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script help
Operating System - HP-UX
1754016
Members
7762
Online
108811
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО12-18-2002 01:28 AM
тАО12-18-2002 01:28 AM
Hi, I've created a script that put PID's in a variable,
(PC='ps -fu petra | grep process | cut -c 14-20') now I want to match this output whit the PPID of the process, so that if the PPID is a specific number then do something.
Any suggestions on how to...
Rgds
Petra
(PC='ps -fu petra | grep process | cut -c 14-20') now I want to match this output whit the PPID of the process, so that if the PPID is a specific number then do something.
Any suggestions on how to...
Rgds
Petra
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2002 01:38 AM
тАО12-18-2002 01:38 AM
Solution
Once you have your pid in $PC then;
ps -fp $PC | awk '{print $3}' | grep -v PPID
returns the PPID of pid $PC
or you enclose the whole thing above into another variable;
PPID=$(ps -fp $PC | awk .....)
ps -fp $PC | awk '{print $3}' | grep -v PPID
returns the PPID of pid $PC
or you enclose the whole thing above into another variable;
PPID=$(ps -fp $PC | awk .....)
Im from Palmerston North, New Zealand, but somehow ended up in London...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2002 01:43 AM
тАО12-18-2002 01:43 AM
Re: script help
You should use awk to pull out the value you want as cut can give wrong values in the way you are using it.
ie on my system
ps -fu root | grep opcmona | cut -c 14-20
Give output of.
2 10702
Where the value of 2 is actually the last digit of the PID and the other numbers are the PPID you are after.
You should use:
PID=`ps -fu petra | grep process | awk '{ print $2 }'`
PPID=`ps -fu petra | grep process | awk '{ print $3 }'`
For an individual process this shoould work perfectly to give you both values you require.
Kind regards,
Robert Thorneycroft
ie on my system
ps -fu root | grep opcmona | cut -c 14-20
Give output of.
2 10702
Where the value of 2 is actually the last digit of the PID and the other numbers are the PPID you are after.
You should use:
PID=`ps -fu petra | grep process | awk '{ print $2 }'`
PPID=`ps -fu petra | grep process | awk '{ print $3 }'`
For an individual process this shoould work perfectly to give you both values you require.
Kind regards,
Robert Thorneycroft
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP