- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Process names
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
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
01-03-2002 02:41 AM
01-03-2002 02:41 AM
Process names
Can anyone help?
I need to enable a script (call it Script2) to find out the Name of the calling script (eg Script1).
I have an idea that the pid or ppid should help but do not know exactly how.
Any suggestions would be welcomed.
Greg Hitchcock
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2002 02:56 AM
01-03-2002 02:56 AM
Re: Process names
How about:
ps -fp $$ | tail -1 | awk '{print $3}' | read PPID
ps -p $PPID | tail -1 | awk '{print $4}'
For a ksh, you don't need the 1st line, since there is a PPID variable created automatically, containing the parent process id.
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2002 02:57 AM
01-03-2002 02:57 AM
Re: Process names
Korn/Posix shells will have the variable ${PPID} set to the parent process.
Given that, you can use ps to find the command and arguments of the parent process. Using the UNIX95 options of ps make it easier so to get the parent's command for instance:-
COMM=$(UNIX95= ps -p ${PPID} -o comm |tail -1)
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2002 03:26 AM
01-03-2002 03:26 AM
Re: Process names
If there is a shell script script1 and you execute the script, the output of "ps -f" will give process name as "-ksh" or "sh", and not as "script1" as expected. So you can get the parent process-id, but in many cases it will be difficult to get the process name.
If the script "script1" is executed as "/bin/sh script1" (or similarly ksh or csh etc.) then "ps -f" will show the script name in last column. Then you can either use PPID variable or "$$" to get parent process-id and it's name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2002 11:33 AM
01-03-2002 11:33 AM
Re: Process names
how about a one-liner:
parent=$(UNIX95= ps -o comm -p $PPID)
HTH,
Wodisch