From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,9631fd6d3795df21,start X-Google-Attributes: gidfee84,public From: tringali@news.ed.ray.com (Scott Tringali) Subject: Re: Executing a CSH command from Digital UNIX C Date: 1996/03/14 Message-ID: <4i9jl8$59l@news.ed.ray.com>#1/1 X-Deja-AN: 142722452 x-disclaimer: This is the author's opinion and not that of Raytheon Company. references: <31448D13.167E@nynexst.com> x-authentication-warning: The author was not authenticated. content-type: text/plain; charset=us-ascii organization: Raytheon Electronic Systems mime-version: 1.0 reply-to: tringali@ultranet.com newsgroups: comp.unix.osf.osf1 Farai Nyoni (farai@nynexst.com) wrote: > I'm not a regular C programmer, but would like to execute a C shell > command from within a C program ( setenv VARIABLE XXX). The error I get > after execution is "setenv: not found" > when I echo the shell before this command I get "/bin/csh" > but after I execute the setenv command I get "/bin/sh" Environment variables are attributes of the process. They are set by the command interpreter, and are not external programs. Thus, you cannot do a system() on "setenv" because there is no such setenv program; it lives inside of csh. To set an environment variable from C: int status; status = putenv("VARNAME=value"); and to read one: char var_p; var_p = getenv("VARNAME"); > Is BOURNE the only environment I can operate in or can I change the > operating shell. Nope. Environment variables are attributes of all processes, but different shells let you change them differently. -- Scott J. Tringali, tringali@ultranet.com Raytheon Electronic Systems, International Air Traffic Control