> Got a bit of a C code using execle() to call a shell script with a 
> specific environment.  I've got no trouble seeing the environment vars 
> in bash.
 
> Is there any way of setting an environment variable in the shell script 
> so that it modifies the environment of the *parent* process?

no there isn't. in a shell script if you want to change the enviornment
you need to do
. script
which actually redirects standard input of the shell to come from script
and reads it in line at a time. A lot of shell commands like cd are
called builtins because they operate in the current process and don't
form subprocesses... because they affect the parent shell process.

The classic Kernighan & Pike book "The Unix Programming Environment" explains
this at length; there are of course good free references.

> I fear not - but is there any way of returning something from a shell 
> other than through an exit status?

Parent and child can co-ordinate in various ways... the obviously easy one
is for the child to write to a temp file and the parent to read the
info from that file and then delete the file; but there are other ways
to do it; this falls under the topic of Interprocess Communication. You 
can install signal handlers in the parent such that when a child terminates
the parent goes and checks interesting things; you also want to look
at the wait() system call.

Hope this helps,
Stuart.
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to