So, I guess the PID and the PPID are always going to be different. I thought I could tell if someone had launched b.ksh directly or if b.ksh was called from a.ksh. I think I will need to check the name of the program for the PPID and compare it to a local variable in b.ksh. Does anyone know how to get the program name for the PPID on Unix Solaris?
Can someone please help me?
I have the following command that gets me what I need on the command line
ps -ef| awk '$2 == 9999 {print $8}' # where 9999 is my current sessions PPID
When I try to put it into my Korn shell it does not behave the same way:
my_var=`ps -ef| awk '$2 == $PPID {print $8}'`
Many awk implementations also allow passing shell variables, either via the -v option, or as trailing argument (after the file to parse).
So you could probably avoid some quoting trouble by e.g.
Since you are on Solaris the awk there knowing this option might be in /usr/xpg4/bin
while the /usr/bin awk could be a little more dumb.
But I think you could further improve by setting up your own format instead of relying on -f
which may change between different ps implementations.
Just tell ps what fields you are interested in.
e.g.
Note, that this would only capture the command.
If you need the command line including arguments substitute -o comm= by -o args=.
Unfortunately, I haven't access to a Solaris box right now, and I don't know by heart.
So I may be wrong, but I think to remember that Solaris also has a pgrep command similar to that found on Linux (I would suggest to refer to man pgrep)
Another, often working way (except in C-shell compatibles (well except on FreeBSD yet where it even works in csh)) is to simply refer to $0 for the current shell, and $- for its arguments.
Then you also might be interested to note that Solaris has a ptree command
similar to pstree on Linux, which will list a process hierarchy tree that could be parsed.
And Solaris even has a rudimentary procfs with a set of accompanying p* commands (like ptree above).
As said, I am only recapitulating this without a system to verify at hands.
Therefore, please check the man pages.
Hello people,
This question might seem to be a little naive but here it goes:
I want to know the PID of a script that is running in the background.
eg: There is a script called Data_Downloader.sh
I am using the command:
ps -ef | grep Data_Downloader.sh
But I am getting the output as
wrkarea... (9 Replies)
Hi,
I need to get the pid of a process and have to store the pid in a variable and i want to use this value(pid) of the variable for some process. Please can anyone tell me how to get the pid of a process and store it in a variable. please help me on this.
Thanks in advance,
Amudha (7 Replies)
Hi All,
In my project i have two process runs in the back end.
Once i start my project, and execute the command ps, i get below output:
PID TTY TIME CMD
9086 pts/1 0:00 ksh
9241 pts/1 0:02 java
9240 pts/1 0:00 shell_script_bg
java with 9241 PID is the main... (4 Replies)
1. If I use an software application(which connects to the database in the server) in my local pc, how many PID should be registered? Would there be PID for the session and another PID for socket connection?
2. I noticed (through netstat) that when I logged in using the my software application,... (1 Reply)
Hi ,
I am trying to get the PID using the following command:
$ /usr/ucb/ps -auwwwwx | grep java | grep Proceess | ptree PID or
$ /usr/ucb/ps -auwwwwx | grep java | grep Proceess;ptree PID
it is possible to get PID, such that I check whether any orphan
process is running.
solution... (0 Replies)
The below command returns full line.How can i get only PID from this line ie 15794 from the below example
(FI NY) nbswpsa52.ny.ficc.gs.com~ ->ps -ef | grep keepalive | grep -v keepaliveStub | grep -v swapback | grep -v grep
ficctprd 15794 1 0 13:12:58 ? 0:01 keepalive (3 Replies)
question: for the below program
i just printed the value for pid, child pid and parent pid
why does it give me 6 values? i assume ppid is 28086
but can't figure out why there are 5 values printed instead of just two!
can someone comment on that!
#include<stdio.h>
#define DIM 8
int... (3 Replies)