Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!cbosgd!ihnp4!mhuxn!mhuxr!ulysses!allegra!mit-eddie!think!harvard!seismo!brl-tgr!tgr!cottrell@nbs-vms.ARPA From: cottrell@nbs-vms.ARPA (COTTRELL, JAMES) Newsgroups: net.lang.c Subject: Setenv from C Message-ID: <1693@brl-tgr.ARPA> Date: Tue, 24-Sep-85 14:41:34 EDT Article-I.D.: brl-tgr.1693 Posted: Tue Sep 24 14:41:34 1985 Date-Received: Sun, 29-Sep-85 04:12:24 EDT Sender: news@brl-tgr.ARPA Lines: 32 /* > Is it possible to set a csh environment variable within a C program? I know > about getenv(), but have failed at attempts to set an environment variable > from a C program. Basically, what I want to do is "source" a new environment > variable for the current csh process. Any comments or suggestions would be > appreciated. Thanks. In a word NO! There is no way to affect your parent's environment unless they made prior arrangements (like before you were born) to do so. Sounds kinda like Life, doesn't it? A way to do this is to set up an alias which runs your program, then sources a file which the program builds. Try the following: alias z 'echo setenv QAZ WSX > EDC ; source EDC' Now type `printenv;z;printenv'. Note the change! Another method might be: setenv NAME `prog` if you only want you change ONE variable & you know it's name. If you want to change more, you can always do: set x = `prog` ; $x I don't know why `prog` by itself on a line doesn't work. Probably because `...` only returns one word. Oh well... jim cottrell@nbs */ ------