Find the answer to your Linux question:
Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By rcgreen
If you have many scripts which may at some point run the script "foofoo.sh", and for some reason you want to keep track of this, is there a way to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Apr 2007
    Posts
    214

    Can a bash script know which other script called it?


    If you have many scripts which may at some point run the script "foofoo.sh", and for some reason you want to keep track of this, is there a way to embed some code in the "foofoo" script so that it generates a log that would look something like:

    9:00 - autostart.sh - foofoo.sh parameters
    10:00 - cron - foofoo.sh parameters 2
    12:00 - fooscript.sh - foofoo.sh parameters
    15:00 - at - foofoo.sh parameters 3


    I know that "parameters" would be "$*" but I have no idea to know "who" called. The time it happened is eye-candy and I can easily solve it, I'm really interesting in knowing who called the script.

    Thanks.
    Openbox + tint2 desktop. Debian testing, liquorix kernel

  2. #2
    Linux Engineer rcgreen's Avatar
    Join Date
    May 2006
    Location
    the hills
    Posts
    1,134
    the dsc likes this.

  3. #3
    Linux Newbie
    Join Date
    Apr 2007
    Posts
    214
    Thanks!

    Keyword to remember when searching for stuff like that, "built-in variable".
    Openbox + tint2 desktop. Debian testing, liquorix kernel

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •