![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Parent child Relation !! using awk/sed ??? | varungupta | UNIX for Advanced & Expert Users | 0 | 01-29-2008 11:24 AM |
| exiting a child without stopping the parent | madpenguin | Shell Programming and Scripting | 5 | 09-19-2007 07:45 PM |
| kill parent and child | larry | UNIX for Dummies Questions & Answers | 4 | 01-11-2003 09:18 PM |
| How hard can it be? ps child/parent | velde046 | Filesystems, Disks and Memory | 2 | 05-25-2002 01:36 PM |
| what are parent and child processes all about? | xyyz | UNIX for Dummies Questions & Answers | 1 | 04-26-2002 12:53 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Parent/Child Processes
Hello.
I have a global function name func1() that I am sourcing in from script A. I call the function from script B. Is there a way to find out which script called func1() dynamically so that the func1() can report it in the event there are errors? Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
I don't think that you can do that through a command. May be something like this?
Code:
# cat test.sh
#!/usr/bin/ksh
func1() {
echo global function
echo $(ps -ef |awk -v pid=$$ '{if($2==pid) print $NF}') has run func1
}
Code:
# cat test1.sh #!/usr/bin/ksh . ./test.sh echo $0 is running func1 echo $0 is ending Code:
# ./test1.sh ./test1.sh is running global function ./test1.sh has run func1 ./test1.sh is ending Note: on Solaris, please use nawk instead of awk. Last edited by blowtorch; 05-31-2006 at 09:12 AM. Reason: adding Solaris note |
|
#3
|
|||
|
|||
|
Works great!! Thank you.
|
|||
| Google The UNIX and Linux Forums |