The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
A program to trace execution of another program jiten_hegde High Level Programming 3 08-19-2008 02:26 AM
returning values from shell script to calling C program nehamore Shell Programming and Scripting 2 02-04-2008 08:09 AM
Calling SHELL script from C program Chanakya.m Shell Programming and Scripting 7 09-21-2007 05:34 PM
pass parameter back to calling program jthomas Shell Programming and Scripting 11 11-20-2003 05:13 AM
Java program calling a UNIX command QUartz Ite UNIX for Dummies Questions & Answers 2 11-15-2001 06:17 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-23-2008
Registered User
 

Join Date: Mar 2007
Posts: 1
calling program

hi,

i have a script.sh on my machine and it used in the system
but my question is how can i know the program called this script.sh??
i.e. from where it called and execute??


Many thanks
Reply With Quote
Forum Sponsor
  #2  
Old 04-23-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
You want to know which program invoked script.sh? A ps listing will reveal the parent PID. It's possible for the parent to exit before the child does, though; then your process will show as orphaned.

Code:
ps wallx | { head -1; grep 'script\.sh'; }
ps options vary wildly between systems; see your local manual page for what will work for you.

The head is just to get the explanatory header as well; in a script, you don't want that.

Example:
Code:
vbvntv$ ps wallx | { head -1; grep to*tem ; }
F   UID   PID  PPID PRI  NI    VSZ   RSS WCHAN  STAT TTY        TIME COMMAND
0  1000  9478     1  15   0 113136 30536 -      SLl  ?         32:30 totem
Here, the parent's PID (PPID) is 1, which is typical for an orphan (the system's init process adopts any orphans).
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0