in reply to Re^2: calling external programs via cgi perl script
in thread calling external programs via cgi perl script

You can't do that, at least not directly. When you run source foo it's in a child shell and only that child shell's environment is modified. When that shell ends, all those modifications go away. See perlfaq8, "I {changed directory, modified my environment} in a perl script. How come the change disappeared when I exited the script? How do I get my changes to be visible?"

You'd need to source the file and run the rest of the commands in the same subshell. Prefix the commands that need the modified environment with the source command separated by a semicolon: source foo ; some_other command

Replies are listed 'Best First'.
Re^4: calling external programs via cgi perl script
by cdarke (Prior) on Mar 23, 2007 at 10:07 UTC
    One other thing to add to the above. You appear to be using csh (you mentioned setenv previously). system and backticks use the Bourne shell, which does not have the source command (uses 'dot' instead) and the syntax for setting variables is different. You will have to explicitly call csh (or tcsh) to get your file to run.
Re^4: calling external programs via cgi perl script
by echoangel911 (Sexton) on Mar 23, 2007 at 13:56 UTC
    for some reason, source foo; doesn't work for me. this is my foo file:
    #!/bin/tcsh set circuit_os = Linux.7.3 setenv CIRCUIT_LIC /tools/circuit/difflib/asdf.lic setenv SERVER_LIC /tools/circuit/difflib/server.lic
    and when I execute this:
    my @lines =`. foo; env`; foreach my $line (@lines) { print "[DEBUG] $line <br>\n"; }
    I don't understand why I'm also getting this:
    sh: line 6: setenv: command not found sh: line 7: setenv: command not found
    I don't see any of those variables in output.

      It doesn't work because you're trying to use csh commands in a Bourne shell. Explicitly run things with csh, or rewrite the environment variable setting script using sh syntax (as cdarke mentioned already above).