[Cook] Passing Environment variables to scripts ?

Jerry Pendergraft jerry at endocardial.com
Fri Oct 8 23:01:11 EST 2004


Actually cook does use a shell to run commands, which one depends on the
users environment. So to clear that up I always put in cook files:
/*P PRIMARY INITIALIZATION */
SHELL = /bin/sh;


Then the foo=bar works. Here is an example where I build up a complex
environment and then run it. The unsplit is handy/necessary to form a
valid command with spaces. 

    local cmd = [unsplit " " 
     [catenate "DISPLAY="       [getenv DISPLAY] ";export DISPLAY;"]
     [catenate "AEGIS_PROJECT=" [project]     ]
     [catenate "AEGIS_CHANGE="  [change]      ]
     [catenate "AEGIS_ARCH="         %1       ]
     [catenate "ARCH_COMP="          %2       ]
     [catenate "BRANCH_PATH="   [search_path] ]
     [catenate "PATH=" [unsplit ":"
        [addsuffix /%1/bin/%2 [branch_path]] [getenv PATH] "/bin" ]]
     [catenate "LD_LIBRARY_PATH=" [unsplit ":"
        [addsuffix /%1/lib/%2 [branch_path]]]]
     [sh_cmd] [resolve [need]] 
    ];

    [cmd];

-- 
Jerry Pendergraft                        jerry.pendergraft at endocardial.com
Endocardial Solutions                    voice: 651-523-6935
1350 Energy Lane, Suite 110                fax: 651-644-7897
St Paul, MN 55108-5254                  mobile: 651-491-0163

On Fri, 1 Oct 2004, John Darrington wrote:

> I've got a function which calls a shell script like:
> 
> function run-script =
> {
>         [ print Running Script [ @1 ] ] ;
> 	[shell [@1]];
> }
> 
> but I want the script to be called with certain environment variables
> set.  How can I do this?  I've tried numerous things similar to:
> 
> 
> function run-script =
> {
>         [ print Running Script [ @1 ] ] ;
> 	[shell FOO=xyzzy [@1]];
> }
> 
> But none of them seem to do the business.  Maybe cook should have a
> setenv function to complement its getenv ?
> 
> J'
> 
> 
> 
> 




More information about the Cook-users mailing list