in reply to Re^2: How do I test if my Perl script was run using a login vs a non-login shell
in thread How do I test if my Perl script was run using a login vs a non-login shell

The difference is that this login shell will be installed on 600 odd servers with different operating systems and I don't want to manage compiling C code across different operating systems.

:) You'll notice my question came before my suggestion, it wasn't about my suggestion

Let me elaborate, what is the difference between using a login vs a non-login shell? What effect does it have upon the execution of a program? Does it set some variables?

I doubt the only effect is a dash in ARGV

You could probably examine some perlvar or some POSIX call, but you'd have to know more about what su does -- I don't know too much about su.

  • Comment on Re^3: How do I test if my PERL script was run using a login vs a non-login shell

Replies are listed 'Best First'.
Re^4: How do I test if my Perl script was run using a login vs a non-login shell
by paulski82 (Novice) on May 23, 2012 at 04:18 UTC

    Login shells typically do different things than non-login shells. For example, the bash shell will behave differently in terms of what user environment scripts it parses and what environment variables it sets, depending on whether it was run as a login or non-login shell, as well as whether it was run in interactive or non-interactive mode (also a command line argument).

    Depending on how it's called, my shell script needs to do different things.

      Login shells typically ...

      Yeah, that is the same generic stuff I've read all over the place, that doesn't explain how login shells determine if they're login shells

      Supposedly both zoid and psh can be run as login shells ( chsh ` which psh` ) but there is nothing obvious about how they determine when they're run as login-shells

      Here you can see http://search.cpan.org/grep?cpanid=GREGOR&release=psh-1.8.1&string=login&i=1&n=1&C=4

      lib/Psh/OS/Win.pm 80-} 81- 82-sub inc_shlvl { 83- if (! $ENV{SHLVL}) { 84: $Psh::login_shell = 1; 85- $ENV{SHLVL} = 1; 86- } else { 87: $Psh::login_shell = 0; 88- $ENV{SHLVL}++; 89- } 90-} 91-
      but that doesn't look spectacularly useful/portable