05-02-2007
Thanks for the help everyone.....
I ended up figuring out the solution pending your assistance....Here is the updated code if anyone cares.....LOL
#!/bin/ksh
touch running.out
pid_file=pid_file.lst
while [ -f running.out ]
do
ps -ef|grep $1|grep -v root|cut -f5 -d" " > $pid_file
ps -ef|grep $1|grep -v root
if [ -s $pid_file ];
then
while read item;
do
xcmd=$(ps -f -p$item|grep $item|cut -c16-20)
echo $(ps -f -p$item|grep $item)
if [ -n $xcmd ];
then
touch looping.out
while [ -f looping.out ]
do
xcmd2=$(ps -f -p$xcmd|grep $xcmd|cut -c16-20)
echo $(ps -f -p$xcmd|grep $xcmd)
if [ -n $xcmd2 -a "${xcmd2}" != ' 0' ];
then
xcmd=$(ps -f -p$xcmd2|grep $xcmd2|cut -c16-20)
echo $(ps -f -p$xcmd2|grep $xcmd2)
else
echo "No additional Parent PID found"
rm looping.out
exit
fi
done
else
echo "No Parent PID found"
fi
done < $pid_file
else
echo "$1 session is not on the system"
rm running.out
fi
done
The output generated looks like this:
# ./tunnel_ppid.sh sqlplus
oracle 7171 3591 0 15:06:29 pts/ta 00:00 /U03/app/oracle/product/10.2.0/bin/sqlplus -s
oracle 7171 3591 0 15:06:29 pts/ta 0:00 /U03/app/oracle/product/10.2.0/bin/sqlplus -s
oracle 3591 5120 0 14:42:57 pts/ta 0:00 /bin/ksh ./refresh_tables.sh
oracle 5120 5069 0 16:24:00 pts/ta 0:00 -su
dc01928 5069 5068 0 16:23:20 pts/ta 0:00 -sh
root 5068 1261 0 16:23:19 pts/ta 0:00 telnetd
root 1261 1 0 16:12:59 ? 0:00 /usr/sbin/inetd -l
root 1 0 0 16:11:49 ? 0:06 init
root 0 0 0 16:11:49 ? 0:22 swapper
No additional Parent PID found
Which shows you the progression of who is ultimately running a process.....
9 More Discussions You Might Find Interesting
1. Programming
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)
Discussion started by: a25khan
3 Replies
2. UNIX for Dummies Questions & Answers
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)
Discussion started by: pcx26
1 Replies
3. Shell Programming and Scripting
Hello everyone , I am looking for a better solution then the one I have created for the my Task
The task is:
Create an automated script that will check for Uploads in a specified Directory and move them to another specified Directory if the files are completely uploaded.
Files are FTP'd to... (2 Replies)
Discussion started by: robertmcol
2 Replies
4. UNIX for Dummies Questions & Answers
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)
Discussion started by: samudha
7 Replies
5. Shell Programming and Scripting
Hi guys!
I have a directory in the production environment from which i have to delete files older then 40 minutes with .pid extention. I wrote a script below for the purpose.
#!/bin/bash
#
# Script to delete specific file older than N minutes.
# OLDERTHAN="40" #40 minutes
... (6 Replies)
Discussion started by: sajid.shah
6 Replies
6. Shell Programming and Scripting
I'm trying to run the script below recursively but it is generating multiple and simultaneous processes. how do I do to start same script again (last line of my script) only after he had just run entirely?
The file name is bachup.sh
I am using this command:
# / bin / bash /
... (8 Replies)
Discussion started by: sprool
8 Replies
7. Shell Programming and Scripting
Hello
i have a requirement where in a file i will get string. The length could be from 1 to 20. if the string is less than 6 characters ( ex: ABCD) . i need to append 'X' on right hand side to make it 6 characters (ex: ABCDXX). if suppose i get the same string from the file as ABCDXX then i... (5 Replies)
Discussion started by: dsdev_123
5 Replies
8. Shell Programming and Scripting
I have a batch of mkv video files I would like to transcode to a more compressed format. After spending a significant amount of time experimenting with various parameters I think I have found the handbrake settings that give the best compromise. I now want to construct a simple bash script... (4 Replies)
Discussion started by: jonesal2
4 Replies
9. Shell Programming and Scripting
Hello. I am trying to create a script that recursively looks at my folder structure, and extracts any .7z files that have not already been extracted yet. I know that all .7z files only have a single .txt file in them, and the only .txt file in any directory would be from that .7z file.
I am... (3 Replies)
Discussion started by: Davinator
3 Replies
ZGREP(1) General Commands Manual ZGREP(1)
NAME
zgrep - search possibly compressed files for a regular expression
SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename...
DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code:
(-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the
standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep.
If the GREP environment variable is set, zgrep uses it as the grep program to be invoked.
EXIT CODE
2 - An option that is not supported was specified.
AUTHOR
Charles Levert (charles@comm.polymtl.ca)
SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1)
ZGREP(1)