hepcat72 has asked for the wisdom of the Perl Monks concerning the following question:
So I had a pipeline recently that someone was running when they got an error, which the ostensibly emailed to me without alteration. The error looked like it was from the first script call in the pipeline because there should have been an echo in between the 2 calls - at least from what I saw pasted in the email. It turned out that the error was from the second script call in the pipeline.
I have a debug mode in which any error gets prepended with the script's name, but you have to explicitly supply a --debug flag and I was thinking that it would be nice if my script could detect when it's immediate parent process is not an interactive tty - and decide to prepend that string automatically.
In an ideal world, it would also be able to tell if it is inside a series of piped commands as opposed to redirected input/output (</>). Theoretically, I would think that this could be possible simply by the number of concurrent processes the parent process has.
However, I feel like both of these things would be very non-trivial to implement. I know I can use -t or -p for piping, but those don't know anything about parent processes and can't tell the difference between | vs. >.
Any thoughts?
Thanks,
Rob
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can a script tell if it is being run from inside a script versus in an interactive terminal session?
by BrowserUk (Patriarch) on Nov 07, 2014 at 20:59 UTC | |
|
Re: Can a script tell if it is being run from inside a script versus in an interactive terminal session?
by boftx (Deacon) on Nov 07, 2014 at 23:30 UTC | |
|
Re: Can a script tell if it is being run from inside a script versus in an interactive terminal session?
by RonW (Parson) on Nov 07, 2014 at 21:42 UTC | |
|
Re: Can a script tell if it is being run from inside a script versus in an interactive terminal session?
by hepcat72 (Sexton) on Nov 12, 2014 at 17:00 UTC | |
|
Re: Can a script tell if it is being run from inside a script versus in an interactive terminal session?
by hepcat72 (Sexton) on Nov 18, 2014 at 01:29 UTC |