in reply to Find name of calling script?
If you're running under Unix (Mac is Unix), then the ps -aef command will show running jobs. ON my Mac ...
UID PID PPID C STIME TTY TIME CMD 0 1 0 0 0:01.00 ?? 0:01.38 /sbin/launchd 0 11 1 0 0:00.82 ?? 0:01.04 /usr/libexec/kextd 0 12 1 0 0:07.11 ?? 0:13.22 /usr/sbin/Directory +Service 0 13 1 0 0:01.11 ?? 0:01.64 /usr/sbin/notifyd 0 14 1 0 0:00.73 ?? 0:01.57 /usr/sbin/syslogd ... 0 347 346 0 0:00.02 ttys000 0:00.03 login -pf tomdlux 503 348 347 0 0:00.11 ttys000 0:00.53 -bash 0 3935 348 0 0:00.00 ttys000 0:00.00 ps -aef
You can see that this 'ps' command had Process ID (PID) 3935, and Parent ID (PPID) 348 ... that's a bash shell which was launched by 'login'
use English '-no_match_vars'; will allow you to use $PID or $PROCESS_ID to see your process id, as will getpid(), described in perldoc perlfunc. The parent id is fetched by getppid(). If you're multi-threaded on Linux, you'll want Linux::PID.
If you're on Windows, you're welcome to switch to Unix.
As Occam said: Entia non sunt multiplicanda praeter necessitatem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Find name of calling script?
by cdarke (Prior) on Nov 13, 2010 at 17:04 UTC |