Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

TorgoX (1933)

TorgoX
  sburkeNO@SPAMcpan.org
http://search.cpan.org/~sburke/

"Il est beau comme la retractilité des serres des oiseaux rapaces [...] et surtout, comme la rencontre fortuite sur une table de dissection d'une machine à coudre et d'un parapluie !" -- Lautréamont

Journal of TorgoX (1933)

Friday July 15, 2005
11:52 PM

Environmental environment

[ #25736 ]
Dear Log,

So, at times, I want to make my programs do slightly different things (like having a different default debug level, for example) depending on whether they're running under crontab, or at a shell prompt, or whatever. What I do is set some env vars in my .cshrc. This is not a one-size-fits-all solution, but it works for me:

if ( $?prompt ) then
  # An interactive session of some kind
  setenv SMB_INTERACTIVE 1
  if( ! $?TERM ) then
    # running like under the winscp "terminal"
    setenv SMB_TERMINAL 0
    set history = 0
  else
    setenv SMB_TERMINAL 1
    # Normal toplevel interactive shell
  endif

  if( ! $?TERM ) then
    # We're under a nonterminal (scp, etc)
  else if( $TERM == screen ) then
    # a Screen window
    alias screen 'echo Already under screen.'
  else if($?SSH_TTY) then
    # Normal SSH stuff
  else
    # Not over SSH -- a local terminal? or telnet!?
  endif
else
  # Not an interactive session.
  setenv SMB_TERMINAL 0
  setenv SMB_INTERACTIVE 0
  set history = 0
endif

Sometimes I want a program to be able to tell when it's being run by an emacs process. For that, I just set this in my .emacs.config:

(setenv "UNDER_EMACS" "1")

Like I say, it's not guaranteed to work everywhere forever, but maybe you can use it.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.