From: tringali@news.ed.ray.com (Scott Tringali)
Subject: Re: Executing a CSH command from Digital UNIX C
Date: 1996/03/14 [thread overview]
Message-ID: <4i9jl8$59l@news.ed.ray.com> (raw)
In-Reply-To: 31448D13.167E@nynexst.com
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
parent reply other threads:[~1996-03-14 5:00 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <31448D13.167E@nynexst.com>]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox