How to pass varibles to csh

Mike Ditto ford at kenobi.UUCP
Mon Feb 29 10:06:51 AEST 1988


Posting-Front-End: GNU Emacs 18.41.10 of Fri Oct  2 1987 on kenobi (usg-unix-v)


In article <2937 at sdsu.UUCP> nash at sdsu.UUCP (Ron Nash) writes:

> How can I pass varibles (other than environment varibles) to /bin/csh?
> I have a C program that uses execve to pass the environment varibles, but
> it does not pass local (the ones shown via the csh 'set' command) to the
> child shell.  Has anyone done this?  Is it possible to set local variables
> from within a C program so that a child will inherit them?

That last sentence summarizes the situation.  A "local" shell variable
is one which was created in the current process and will not be passed
to any other processes.  Local variables are meant to be used as their
name suggests, as local variables.  Variables which are inherited by
exec'ed processes are called "environment variables", and you obviously
know how to use those.

Apparently, your goal is to run a csh that will define some shell
variables before beginning to execute commands.  There is no
straightforward way to do this, but you can put "set" statements in
the .cshrc file, or at the beginning of the script to be executed.  If
that is not acceptable, or if you are creating an interactive csh, try
something like

	/* autologout=42 is just an example, replace with your assignments */
	execlp("/bin/csh", "csh", "-ci", "set autologout=42;source /dev/tty");

although I don't know if prompting will work properly.

					-=] Ford [=-

"Well, he didn't know what to do, so	(In Real Life:  Mike Ditto)
he decided to look at the government,	ford%kenobi at crash.CTS.COM
to see what they did, and scale it	...!sdcsvax!crash!kenobi!ford
down and run his life that way." -- Laurie Anderson



More information about the Comp.unix.wizards mailing list