in reply to Environment Variable Setting

When you source a file in the shell, that actually does what you want -- it doesn't create a sub-shell, but interprets the file in the current shell, allowing it to change the environment. That's unlike running the script as an executable, which does fire up a new shell process, which is unable to change the environment of its parent. So source sge_sigma.csh should do what you want.

Aaron B.
My Woefully Neglected Blog, where I occasionally mention Perl.

Replies are listed 'Best First'.
Re^2: Environment Variable Setting
by austinj (Acolyte) on Apr 23, 2012 at 19:03 UTC

    this is only true within csh correct? I can't simply

    source sge_sigma.csh;

    Does perl have a "source" command?

    system("source sge_sigma.csh");

    doesn't work

    Thanks!

      If you're in a csh shell (or most other shells), then yes, entering source sge_sigma.csh at the command line will cause the contents of that file to be interpreted and take effect in the current shell.

      bannor:~/work/perl/monks$ csh bannor:~/work/perl/monks> cat test.csh setenv MYTEST "This is a test." bannor:~/work/perl/monks> echo $MYTEST MYTEST: Undefined variable. bannor:~/work/perl/monks> source test.csh bannor:~/work/perl/monks> echo $MYTEST This is a test.

      You can't do this from within a Perl script, because it's a sub-process of the shell, so it can't change its parent's environment. To put it another way, you can change environment variables within a Perl script by use of the %ENV hash, and those will be inherited by any child processes that your Perl script spawns, but they can't go "upstream" to the parent process.

      Aaron B.
      My Woefully Neglected Blog, where I occasionally mention Perl.