in reply to Re: How Was My Script Run?
in thread How Was My Script Run?

So I'd have to do it by using a parameter as a flag? Is that the only way, or is there any way for a script to tell, such as by looking at input or output or something else that I wouldn't specify in a parameter?

Replies are listed 'Best First'.
Re^3: How Was My Script Run?
by Anonymous Monk on Mar 15, 2011 at 07:44 UTC
    So I'd have to do it by using a parameter as a flag? Is that the only way, or is there any way for a script to tell, such as by looking at input or output or something else that I wouldn't specify in a parameter?

    Parameters are delicious, learn to love them :)

      Oh, I use parameters for quite a bit, but while in testing, and dealing with an issue with a learning disability, I run into issues where I might use the parameters when launching from one routine, but not from another and I know I won't remember it if I need to use it from the command line.

      My intent here is for the launched program to be able to check something quickly and easily and know if it's run by another Perl program or from the command line. I'm also mistake-proofing it for later, so if I (or those I'm working with) run it from the command line with the wrong argument, it'll still know for sure.

      So, in this case, I think the easiest and best way is to have some way besides a parameter to verify what's running a script. I knew, before I asked, there was likely some way, since I see how output for some bash commands differs depending on if they're sending output to STDOUT or to a file.