Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to test if a shell script is run from command-line

Dude!Jul 22 2012 — edited Jul 22 2012
I'm trying to figure out a way how to check if a script is run from command-line or executed by the system, e.g. init process.

I thought I could use interactive vs. non-interactive, but that does not work. According to the bash buildin $- variable, a script, when executing, it's always non-interactive. I also tried checking for $PS1 or [ -t, but it seems testing whether a process is interactive or non-interactive is not the solution.

Any ideas?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 19 2012
Added on Jul 22 2012
4 comments
356 views